Commit 24f7a70d authored by sigurds@chromium.org's avatar sigurds@chromium.org

Provide mutators in NodeProperties instead of exposing indicies.

BUG=
R=mstarzinger@chromium.org

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

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@23074 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent d9828280
...@@ -23,13 +23,12 @@ namespace compiler { ...@@ -23,13 +23,12 @@ namespace compiler {
// Inputs are always arranged in order as follows: // Inputs are always arranged in order as follows:
// 0 [ values, context, effects, control ] node->InputCount() // 0 [ values, context, effects, control ] node->InputCount()
inline int NodeProperties::FirstValueIndex(Node* node) { return 0; }
inline int NodeProperties::GetContextIndex(Node* node) { inline int NodeProperties::FirstContextIndex(Node* node) {
return PastValueIndex(node); return PastValueIndex(node);
} }
inline int NodeProperties::FirstValueIndex(Node* node) { return 0; }
inline int NodeProperties::FirstEffectIndex(Node* node) { inline int NodeProperties::FirstEffectIndex(Node* node) {
return PastContextIndex(node); return PastContextIndex(node);
} }
...@@ -45,7 +44,7 @@ inline int NodeProperties::PastValueIndex(Node* node) { ...@@ -45,7 +44,7 @@ inline int NodeProperties::PastValueIndex(Node* node) {
} }
inline int NodeProperties::PastContextIndex(Node* node) { inline int NodeProperties::PastContextIndex(Node* node) {
return GetContextIndex(node) + return FirstContextIndex(node) +
OperatorProperties::GetContextInputCount(node->op()); OperatorProperties::GetContextInputCount(node->op());
} }
...@@ -71,7 +70,7 @@ inline Node* NodeProperties::GetValueInput(Node* node, int index) { ...@@ -71,7 +70,7 @@ inline Node* NodeProperties::GetValueInput(Node* node, int index) {
inline Node* NodeProperties::GetContextInput(Node* node) { inline Node* NodeProperties::GetContextInput(Node* node) {
DCHECK(OperatorProperties::HasContextInput(node->op())); DCHECK(OperatorProperties::HasContextInput(node->op()));
return node->InputAt(GetContextIndex(node)); return node->InputAt(FirstContextIndex(node));
} }
inline Node* NodeProperties::GetEffectInput(Node* node, int index) { inline Node* NodeProperties::GetEffectInput(Node* node, int index) {
...@@ -106,7 +105,7 @@ inline bool NodeProperties::IsValueEdge(Node::Edge edge) { ...@@ -106,7 +105,7 @@ inline bool NodeProperties::IsValueEdge(Node::Edge edge) {
inline bool NodeProperties::IsContextEdge(Node::Edge edge) { inline bool NodeProperties::IsContextEdge(Node::Edge edge) {
Node* node = edge.from(); Node* node = edge.from();
return IsInputRange(edge, GetContextIndex(node), return IsInputRange(edge, FirstContextIndex(node),
OperatorProperties::GetContextInputCount(node->op())); OperatorProperties::GetContextInputCount(node->op()));
} }
...@@ -134,13 +133,14 @@ inline bool NodeProperties::IsControl(Node* node) { ...@@ -134,13 +133,14 @@ inline bool NodeProperties::IsControl(Node* node) {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// Miscellaneous mutators. // Miscellaneous mutators.
inline void NodeProperties::ReplaceControlInput(Node* node, Node* control) {
node->ReplaceInput(FirstControlIndex(node), control);
}
inline void NodeProperties::ReplaceEffectInput(Node* node, Node* effect, inline void NodeProperties::ReplaceEffectInput(Node* node, Node* effect,
int index) { int index) {
DCHECK(index < OperatorProperties::GetEffectInputCount(node->op())); DCHECK(index < OperatorProperties::GetEffectInputCount(node->op()));
return node->ReplaceInput( return node->ReplaceInput(FirstEffectIndex(node) + index, effect);
OperatorProperties::GetValueInputCount(node->op()) +
OperatorProperties::GetContextInputCount(node->op()) + index,
effect);
} }
inline void NodeProperties::RemoveNonValueInputs(Node* node) { inline void NodeProperties::RemoveNonValueInputs(Node* node) {
......
...@@ -29,6 +29,7 @@ class NodeProperties { ...@@ -29,6 +29,7 @@ class NodeProperties {
static inline bool IsControl(Node* node); static inline bool IsControl(Node* node);
static inline void ReplaceControlInput(Node* node, Node* control);
static inline void ReplaceEffectInput(Node* node, Node* effect, static inline void ReplaceEffectInput(Node* node, Node* effect,
int index = 0); int index = 0);
static inline void RemoveNonValueInputs(Node* node); static inline void RemoveNonValueInputs(Node* node);
...@@ -36,9 +37,9 @@ class NodeProperties { ...@@ -36,9 +37,9 @@ class NodeProperties {
static inline Bounds GetBounds(Node* node); static inline Bounds GetBounds(Node* node);
static inline void SetBounds(Node* node, Bounds bounds); static inline void SetBounds(Node* node, Bounds bounds);
static inline int GetContextIndex(Node* node); private:
static inline int FirstValueIndex(Node* node); static inline int FirstValueIndex(Node* node);
static inline int FirstContextIndex(Node* node);
static inline int FirstEffectIndex(Node* node); static inline int FirstEffectIndex(Node* node);
static inline int FirstControlIndex(Node* node); static inline int FirstControlIndex(Node* node);
static inline int PastValueIndex(Node* node); static inline int PastValueIndex(Node* node);
......
...@@ -707,7 +707,7 @@ class TestingGraph : public HandleAndZoneScope, public GraphAndBuilders { ...@@ -707,7 +707,7 @@ class TestingGraph : public HandleAndZoneScope, public GraphAndBuilders {
Node* tb = graph()->NewNode(common()->IfTrue(), br); Node* tb = graph()->NewNode(common()->IfTrue(), br);
Node* fb = graph()->NewNode(common()->IfFalse(), br); Node* fb = graph()->NewNode(common()->IfFalse(), br);
Node* m = graph()->NewNode(common()->Merge(2), tb, fb); Node* m = graph()->NewNode(common()->Merge(2), tb, fb);
ret->ReplaceInput(NodeProperties::FirstControlIndex(ret), m); NodeProperties::ReplaceControlInput(ret, m);
return br; return br;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment