OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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 #include "src/compiler/common-operator.h" | 5 #include "src/compiler/common-operator.h" |
6 #include "src/compiler/graph.h" | 6 #include "src/compiler/graph.h" |
7 #include "src/compiler/node-properties.h" | 7 #include "src/compiler/node-properties.h" |
8 #include "src/compiler/operator-properties.h" | 8 #include "src/compiler/operator-properties.h" |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 } else { | 190 } else { |
191 DCHECK_NOT_NULL(value); | 191 DCHECK_NOT_NULL(value); |
192 edge.UpdateTo(value); | 192 edge.UpdateTo(value); |
193 } | 193 } |
194 } | 194 } |
195 } | 195 } |
196 | 196 |
197 | 197 |
198 // static | 198 // static |
199 void NodeProperties::ChangeOp(Node* node, const Operator* new_op) { | 199 void NodeProperties::ChangeOp(Node* node, const Operator* new_op) { |
200 DCHECK_EQ(OperatorProperties::GetTotalInputCount(new_op), node->InputCount()); | |
201 node->set_op(new_op); | 200 node->set_op(new_op); |
| 201 |
| 202 #ifdef DEBUG |
| 203 Verify(node); |
| 204 #endif // DEBUG |
202 } | 205 } |
203 | 206 |
204 | 207 |
205 // static | 208 // static |
206 Node* NodeProperties::FindProjection(Node* node, size_t projection_index) { | 209 Node* NodeProperties::FindProjection(Node* node, size_t projection_index) { |
207 for (auto use : node->uses()) { | 210 for (auto use : node->uses()) { |
208 if (use->opcode() == IrOpcode::kProjection && | 211 if (use->opcode() == IrOpcode::kProjection && |
209 ProjectionIndexOf(use->op()) == projection_index) { | 212 ProjectionIndexOf(use->op()) == projection_index) { |
210 return use; | 213 return use; |
211 } | 214 } |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 } | 264 } |
262 #ifdef DEBUG | 265 #ifdef DEBUG |
263 for (size_t index = 0; index < projection_count; ++index) { | 266 for (size_t index = 0; index < projection_count; ++index) { |
264 DCHECK_NOT_NULL(projections[index]); | 267 DCHECK_NOT_NULL(projections[index]); |
265 } | 268 } |
266 #endif | 269 #endif |
267 } | 270 } |
268 | 271 |
269 | 272 |
270 // static | 273 // static |
| 274 void NodeProperties::Verify(Node* node) { |
| 275 CHECK_EQ(OperatorProperties::GetTotalInputCount(node->op()), |
| 276 node->InputCount()); |
| 277 // If this node has no effect or no control outputs, |
| 278 // we check that no its uses are effect or control inputs. |
| 279 bool check_no_control = node->op()->ControlOutputCount() == 0; |
| 280 bool check_no_effect = node->op()->EffectOutputCount() == 0; |
| 281 bool check_no_frame_state = node->opcode() != IrOpcode::kFrameState; |
| 282 if (check_no_effect || check_no_control) { |
| 283 for (Edge edge : node->use_edges()) { |
| 284 Node* const user = edge.from(); |
| 285 CHECK(!user->IsDead()); |
| 286 if (NodeProperties::IsControlEdge(edge)) { |
| 287 CHECK(!check_no_control); |
| 288 } else if (NodeProperties::IsEffectEdge(edge)) { |
| 289 CHECK(!check_no_effect); |
| 290 } else if (NodeProperties::IsFrameStateEdge(edge)) { |
| 291 CHECK(!check_no_frame_state); |
| 292 } |
| 293 } |
| 294 } |
| 295 // Frame state inputs should be frame states (or sentinels). |
| 296 for (int i = 0; i < OperatorProperties::GetFrameStateInputCount(node->op()); |
| 297 i++) { |
| 298 Node* input = NodeProperties::GetFrameStateInput(node, i); |
| 299 CHECK(input->opcode() == IrOpcode::kFrameState || |
| 300 input->opcode() == IrOpcode::kStart || |
| 301 input->opcode() == IrOpcode::kDead); |
| 302 } |
| 303 // Effect inputs should be effect-producing nodes (or sentinels). |
| 304 for (int i = 0; i < node->op()->EffectInputCount(); i++) { |
| 305 Node* input = NodeProperties::GetEffectInput(node, i); |
| 306 CHECK(input->op()->EffectOutputCount() > 0 || |
| 307 input->opcode() == IrOpcode::kDead); |
| 308 } |
| 309 // Control inputs should be control-producing nodes (or sentinels). |
| 310 for (int i = 0; i < node->op()->ControlInputCount(); i++) { |
| 311 Node* input = NodeProperties::GetControlInput(node, i); |
| 312 CHECK(input->op()->ControlOutputCount() > 0 || |
| 313 input->opcode() == IrOpcode::kDead); |
| 314 } |
| 315 } |
| 316 |
| 317 |
| 318 // static |
271 bool NodeProperties::AllValueInputsAreTyped(Node* node) { | 319 bool NodeProperties::AllValueInputsAreTyped(Node* node) { |
272 int input_count = node->op()->ValueInputCount(); | 320 int input_count = node->op()->ValueInputCount(); |
273 for (int index = 0; index < input_count; ++index) { | 321 for (int index = 0; index < input_count; ++index) { |
274 if (!IsTyped(GetValueInput(node, index))) return false; | 322 if (!IsTyped(GetValueInput(node, index))) return false; |
275 } | 323 } |
276 return true; | 324 return true; |
277 } | 325 } |
278 | 326 |
279 | 327 |
280 // static | 328 // static |
281 bool NodeProperties::IsInputRange(Edge edge, int first, int num) { | 329 bool NodeProperties::IsInputRange(Edge edge, int first, int num) { |
282 if (num == 0) return false; | 330 if (num == 0) return false; |
283 int const index = edge.index(); | 331 int const index = edge.index(); |
284 return first <= index && index < first + num; | 332 return first <= index && index < first + num; |
285 } | 333 } |
286 | 334 |
287 } // namespace compiler | 335 } // namespace compiler |
288 } // namespace internal | 336 } // namespace internal |
289 } // namespace v8 | 337 } // namespace v8 |
OLD | NEW |