| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_COMPILER_NODE_PROPERTIES_INL_H_ | 5 #ifndef V8_COMPILER_NODE_PROPERTIES_INL_H_ |
| 6 #define V8_COMPILER_NODE_PROPERTIES_INL_H_ | 6 #define V8_COMPILER_NODE_PROPERTIES_INL_H_ |
| 7 | 7 |
| 8 #include "src/v8.h" | 8 #include "src/v8.h" |
| 9 | 9 |
| 10 #include "src/compiler/common-operator.h" | 10 #include "src/compiler/common-operator.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 inline int NodeProperties::FirstEffectIndex(Node* node) { | 37 inline int NodeProperties::FirstEffectIndex(Node* node) { |
| 38 return PastFrameStateIndex(node); | 38 return PastFrameStateIndex(node); |
| 39 } | 39 } |
| 40 | 40 |
| 41 inline int NodeProperties::FirstControlIndex(Node* node) { | 41 inline int NodeProperties::FirstControlIndex(Node* node) { |
| 42 return PastEffectIndex(node); | 42 return PastEffectIndex(node); |
| 43 } | 43 } |
| 44 | 44 |
| 45 | 45 |
| 46 inline int NodeProperties::PastValueIndex(Node* node) { | 46 inline int NodeProperties::PastValueIndex(Node* node) { |
| 47 return FirstValueIndex(node) + | 47 return FirstValueIndex(node) + node->op()->ValueInputCount(); |
| 48 OperatorProperties::GetValueInputCount(node->op()); | |
| 49 } | 48 } |
| 50 | 49 |
| 51 inline int NodeProperties::PastContextIndex(Node* node) { | 50 inline int NodeProperties::PastContextIndex(Node* node) { |
| 52 return FirstContextIndex(node) + | 51 return FirstContextIndex(node) + |
| 53 OperatorProperties::GetContextInputCount(node->op()); | 52 OperatorProperties::GetContextInputCount(node->op()); |
| 54 } | 53 } |
| 55 | 54 |
| 56 inline int NodeProperties::PastFrameStateIndex(Node* node) { | 55 inline int NodeProperties::PastFrameStateIndex(Node* node) { |
| 57 return FirstFrameStateIndex(node) + | 56 return FirstFrameStateIndex(node) + |
| 58 OperatorProperties::GetFrameStateInputCount(node->op()); | 57 OperatorProperties::GetFrameStateInputCount(node->op()); |
| 59 } | 58 } |
| 60 | 59 |
| 61 inline int NodeProperties::PastEffectIndex(Node* node) { | 60 inline int NodeProperties::PastEffectIndex(Node* node) { |
| 62 return FirstEffectIndex(node) + | 61 return FirstEffectIndex(node) + node->op()->EffectInputCount(); |
| 63 OperatorProperties::GetEffectInputCount(node->op()); | |
| 64 } | 62 } |
| 65 | 63 |
| 66 inline int NodeProperties::PastControlIndex(Node* node) { | 64 inline int NodeProperties::PastControlIndex(Node* node) { |
| 67 return FirstControlIndex(node) + | 65 return FirstControlIndex(node) + node->op()->ControlInputCount(); |
| 68 OperatorProperties::GetControlInputCount(node->op()); | |
| 69 } | 66 } |
| 70 | 67 |
| 71 | 68 |
| 72 // ----------------------------------------------------------------------------- | 69 // ----------------------------------------------------------------------------- |
| 73 // Input accessors. | 70 // Input accessors. |
| 74 | 71 |
| 75 inline Node* NodeProperties::GetValueInput(Node* node, int index) { | 72 inline Node* NodeProperties::GetValueInput(Node* node, int index) { |
| 76 DCHECK(0 <= index && | 73 DCHECK(0 <= index && index < node->op()->ValueInputCount()); |
| 77 index < OperatorProperties::GetValueInputCount(node->op())); | |
| 78 return node->InputAt(FirstValueIndex(node) + index); | 74 return node->InputAt(FirstValueIndex(node) + index); |
| 79 } | 75 } |
| 80 | 76 |
| 81 inline Node* NodeProperties::GetContextInput(Node* node) { | 77 inline Node* NodeProperties::GetContextInput(Node* node) { |
| 82 DCHECK(OperatorProperties::HasContextInput(node->op())); | 78 DCHECK(OperatorProperties::HasContextInput(node->op())); |
| 83 return node->InputAt(FirstContextIndex(node)); | 79 return node->InputAt(FirstContextIndex(node)); |
| 84 } | 80 } |
| 85 | 81 |
| 86 inline Node* NodeProperties::GetFrameStateInput(Node* node) { | 82 inline Node* NodeProperties::GetFrameStateInput(Node* node) { |
| 87 DCHECK(OperatorProperties::HasFrameStateInput(node->op())); | 83 DCHECK(OperatorProperties::HasFrameStateInput(node->op())); |
| 88 return node->InputAt(FirstFrameStateIndex(node)); | 84 return node->InputAt(FirstFrameStateIndex(node)); |
| 89 } | 85 } |
| 90 | 86 |
| 91 inline Node* NodeProperties::GetEffectInput(Node* node, int index) { | 87 inline Node* NodeProperties::GetEffectInput(Node* node, int index) { |
| 92 DCHECK(0 <= index && | 88 DCHECK(0 <= index && index < node->op()->EffectInputCount()); |
| 93 index < OperatorProperties::GetEffectInputCount(node->op())); | |
| 94 return node->InputAt(FirstEffectIndex(node) + index); | 89 return node->InputAt(FirstEffectIndex(node) + index); |
| 95 } | 90 } |
| 96 | 91 |
| 97 inline Node* NodeProperties::GetControlInput(Node* node, int index) { | 92 inline Node* NodeProperties::GetControlInput(Node* node, int index) { |
| 98 DCHECK(0 <= index && | 93 DCHECK(0 <= index && index < node->op()->ControlInputCount()); |
| 99 index < OperatorProperties::GetControlInputCount(node->op())); | |
| 100 return node->InputAt(FirstControlIndex(node) + index); | 94 return node->InputAt(FirstControlIndex(node) + index); |
| 101 } | 95 } |
| 102 | 96 |
| 103 inline int NodeProperties::GetFrameStateIndex(Node* node) { | 97 inline int NodeProperties::GetFrameStateIndex(Node* node) { |
| 104 DCHECK(OperatorProperties::HasFrameStateInput(node->op())); | 98 DCHECK(OperatorProperties::HasFrameStateInput(node->op())); |
| 105 return FirstFrameStateIndex(node); | 99 return FirstFrameStateIndex(node); |
| 106 } | 100 } |
| 107 | 101 |
| 108 // ----------------------------------------------------------------------------- | 102 // ----------------------------------------------------------------------------- |
| 109 // Edge kinds. | 103 // Edge kinds. |
| 110 | 104 |
| 111 inline bool NodeProperties::IsInputRange(Node::Edge edge, int first, int num) { | 105 inline bool NodeProperties::IsInputRange(Node::Edge edge, int first, int num) { |
| 112 // TODO(titzer): edge.index() is linear time; | 106 // TODO(titzer): edge.index() is linear time; |
| 113 // edges maybe need to be marked as value/effect/control. | 107 // edges maybe need to be marked as value/effect/control. |
| 114 if (num == 0) return false; | 108 if (num == 0) return false; |
| 115 int index = edge.index(); | 109 int index = edge.index(); |
| 116 return first <= index && index < first + num; | 110 return first <= index && index < first + num; |
| 117 } | 111 } |
| 118 | 112 |
| 119 inline bool NodeProperties::IsValueEdge(Node::Edge edge) { | 113 inline bool NodeProperties::IsValueEdge(Node::Edge edge) { |
| 120 Node* node = edge.from(); | 114 Node* node = edge.from(); |
| 121 return IsInputRange(edge, FirstValueIndex(node), | 115 return IsInputRange(edge, FirstValueIndex(node), |
| 122 OperatorProperties::GetValueInputCount(node->op())); | 116 node->op()->ValueInputCount()); |
| 123 } | 117 } |
| 124 | 118 |
| 125 inline bool NodeProperties::IsContextEdge(Node::Edge edge) { | 119 inline bool NodeProperties::IsContextEdge(Node::Edge edge) { |
| 126 Node* node = edge.from(); | 120 Node* node = edge.from(); |
| 127 return IsInputRange(edge, FirstContextIndex(node), | 121 return IsInputRange(edge, FirstContextIndex(node), |
| 128 OperatorProperties::GetContextInputCount(node->op())); | 122 OperatorProperties::GetContextInputCount(node->op())); |
| 129 } | 123 } |
| 130 | 124 |
| 131 inline bool NodeProperties::IsEffectEdge(Node::Edge edge) { | 125 inline bool NodeProperties::IsEffectEdge(Node::Edge edge) { |
| 132 Node* node = edge.from(); | 126 Node* node = edge.from(); |
| 133 return IsInputRange(edge, FirstEffectIndex(node), | 127 return IsInputRange(edge, FirstEffectIndex(node), |
| 134 OperatorProperties::GetEffectInputCount(node->op())); | 128 node->op()->EffectInputCount()); |
| 135 } | 129 } |
| 136 | 130 |
| 137 inline bool NodeProperties::IsControlEdge(Node::Edge edge) { | 131 inline bool NodeProperties::IsControlEdge(Node::Edge edge) { |
| 138 Node* node = edge.from(); | 132 Node* node = edge.from(); |
| 139 return IsInputRange(edge, FirstControlIndex(node), | 133 return IsInputRange(edge, FirstControlIndex(node), |
| 140 OperatorProperties::GetControlInputCount(node->op())); | 134 node->op()->ControlInputCount()); |
| 141 } | 135 } |
| 142 | 136 |
| 143 | 137 |
| 144 // ----------------------------------------------------------------------------- | 138 // ----------------------------------------------------------------------------- |
| 145 // Miscellaneous predicates. | 139 // Miscellaneous predicates. |
| 146 | 140 |
| 147 inline bool NodeProperties::IsControl(Node* node) { | 141 inline bool NodeProperties::IsControl(Node* node) { |
| 148 return IrOpcode::IsControlOpcode(node->opcode()); | 142 return IrOpcode::IsControlOpcode(node->opcode()); |
| 149 } | 143 } |
| 150 | 144 |
| 151 | 145 |
| 152 // ----------------------------------------------------------------------------- | 146 // ----------------------------------------------------------------------------- |
| 153 // Miscellaneous mutators. | 147 // Miscellaneous mutators. |
| 154 | 148 |
| 155 inline void NodeProperties::ReplaceControlInput(Node* node, Node* control) { | 149 inline void NodeProperties::ReplaceControlInput(Node* node, Node* control) { |
| 156 node->ReplaceInput(FirstControlIndex(node), control); | 150 node->ReplaceInput(FirstControlIndex(node), control); |
| 157 } | 151 } |
| 158 | 152 |
| 159 inline void NodeProperties::ReplaceEffectInput(Node* node, Node* effect, | 153 inline void NodeProperties::ReplaceEffectInput(Node* node, Node* effect, |
| 160 int index) { | 154 int index) { |
| 161 DCHECK(index < OperatorProperties::GetEffectInputCount(node->op())); | 155 DCHECK(index < node->op()->EffectInputCount()); |
| 162 return node->ReplaceInput(FirstEffectIndex(node) + index, effect); | 156 return node->ReplaceInput(FirstEffectIndex(node) + index, effect); |
| 163 } | 157 } |
| 164 | 158 |
| 165 inline void NodeProperties::ReplaceFrameStateInput(Node* node, | 159 inline void NodeProperties::ReplaceFrameStateInput(Node* node, |
| 166 Node* frame_state) { | 160 Node* frame_state) { |
| 167 DCHECK(OperatorProperties::HasFrameStateInput(node->op())); | 161 DCHECK(OperatorProperties::HasFrameStateInput(node->op())); |
| 168 node->ReplaceInput(FirstFrameStateIndex(node), frame_state); | 162 node->ReplaceInput(FirstFrameStateIndex(node), frame_state); |
| 169 } | 163 } |
| 170 | 164 |
| 171 inline void NodeProperties::RemoveNonValueInputs(Node* node) { | 165 inline void NodeProperties::RemoveNonValueInputs(Node* node) { |
| 172 node->TrimInputCount(OperatorProperties::GetValueInputCount(node->op())); | 166 node->TrimInputCount(node->op()->ValueInputCount()); |
| 173 } | 167 } |
| 174 | 168 |
| 175 | 169 |
| 176 // Replace value uses of {node} with {value} and effect uses of {node} with | 170 // Replace value uses of {node} with {value} and effect uses of {node} with |
| 177 // {effect}. If {effect == NULL}, then use the effect input to {node}. | 171 // {effect}. If {effect == NULL}, then use the effect input to {node}. |
| 178 inline void NodeProperties::ReplaceWithValue(Node* node, Node* value, | 172 inline void NodeProperties::ReplaceWithValue(Node* node, Node* value, |
| 179 Node* effect) { | 173 Node* effect) { |
| 180 DCHECK(!OperatorProperties::HasControlOutput(node->op())); | 174 DCHECK(node->op()->ControlOutputCount() == 0); |
| 181 if (effect == NULL && OperatorProperties::HasEffectInput(node->op())) { | 175 if (effect == NULL && node->op()->EffectInputCount() > 0) { |
| 182 effect = NodeProperties::GetEffectInput(node); | 176 effect = NodeProperties::GetEffectInput(node); |
| 183 } | 177 } |
| 184 | 178 |
| 185 // Requires distinguishing between value and effect edges. | 179 // Requires distinguishing between value and effect edges. |
| 186 UseIter iter = node->uses().begin(); | 180 UseIter iter = node->uses().begin(); |
| 187 while (iter != node->uses().end()) { | 181 while (iter != node->uses().end()) { |
| 188 if (NodeProperties::IsEffectEdge(iter.edge())) { | 182 if (NodeProperties::IsEffectEdge(iter.edge())) { |
| 189 DCHECK_NE(NULL, effect); | 183 DCHECK_NE(NULL, effect); |
| 190 iter = iter.UpdateToAndIncrement(effect); | 184 iter = iter.UpdateToAndIncrement(effect); |
| 191 } else { | 185 } else { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 208 DCHECK(IsTyped(node)); | 202 DCHECK(IsTyped(node)); |
| 209 return node->bounds(); | 203 return node->bounds(); |
| 210 } | 204 } |
| 211 | 205 |
| 212 inline void NodeProperties::SetBounds(Node* node, Bounds b) { | 206 inline void NodeProperties::SetBounds(Node* node, Bounds b) { |
| 213 DCHECK(b.lower != NULL && b.upper != NULL); | 207 DCHECK(b.lower != NULL && b.upper != NULL); |
| 214 node->set_bounds(b); | 208 node->set_bounds(b); |
| 215 } | 209 } |
| 216 | 210 |
| 217 inline bool NodeProperties::AllValueInputsAreTyped(Node* node) { | 211 inline bool NodeProperties::AllValueInputsAreTyped(Node* node) { |
| 218 int input_count = OperatorProperties::GetValueInputCount(node->op()); | 212 int input_count = node->op()->ValueInputCount(); |
| 219 for (int i = 0; i < input_count; ++i) { | 213 for (int i = 0; i < input_count; ++i) { |
| 220 if (!IsTyped(GetValueInput(node, i))) return false; | 214 if (!IsTyped(GetValueInput(node, i))) return false; |
| 221 } | 215 } |
| 222 return true; | 216 return true; |
| 223 } | 217 } |
| 224 | 218 |
| 225 | 219 |
| 226 } | 220 } |
| 227 } | 221 } |
| 228 } // namespace v8::internal::compiler | 222 } // namespace v8::internal::compiler |
| 229 | 223 |
| 230 #endif // V8_COMPILER_NODE_PROPERTIES_INL_H_ | 224 #endif // V8_COMPILER_NODE_PROPERTIES_INL_H_ |
| OLD | NEW |