| 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 #include "src/compiler/verifier.h" |
| 9 | 10 |
| 10 namespace v8 { | 11 namespace v8 { |
| 11 namespace internal { | 12 namespace internal { |
| 12 namespace compiler { | 13 namespace compiler { |
| 13 | 14 |
| 14 // static | 15 // static |
| 15 int NodeProperties::PastValueIndex(Node* node) { | 16 int NodeProperties::PastValueIndex(Node* node) { |
| 16 return FirstValueIndex(node) + node->op()->ValueInputCount(); | 17 return FirstValueIndex(node) + node->op()->ValueInputCount(); |
| 17 } | 18 } |
| 18 | 19 |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 DCHECK_NOT_NULL(value); | 192 DCHECK_NOT_NULL(value); |
| 192 edge.UpdateTo(value); | 193 edge.UpdateTo(value); |
| 193 } | 194 } |
| 194 } | 195 } |
| 195 } | 196 } |
| 196 | 197 |
| 197 | 198 |
| 198 // static | 199 // static |
| 199 void NodeProperties::ChangeOp(Node* node, const Operator* new_op) { | 200 void NodeProperties::ChangeOp(Node* node, const Operator* new_op) { |
| 200 node->set_op(new_op); | 201 node->set_op(new_op); |
| 201 | 202 Verifier::VerifyNode(node); |
| 202 #ifdef DEBUG | |
| 203 Verify(node); | |
| 204 #endif // DEBUG | |
| 205 } | 203 } |
| 206 | 204 |
| 207 | 205 |
| 208 // static | 206 // static |
| 209 Node* NodeProperties::FindProjection(Node* node, size_t projection_index) { | 207 Node* NodeProperties::FindProjection(Node* node, size_t projection_index) { |
| 210 for (auto use : node->uses()) { | 208 for (auto use : node->uses()) { |
| 211 if (use->opcode() == IrOpcode::kProjection && | 209 if (use->opcode() == IrOpcode::kProjection && |
| 212 ProjectionIndexOf(use->op()) == projection_index) { | 210 ProjectionIndexOf(use->op()) == projection_index) { |
| 213 return use; | 211 return use; |
| 214 } | 212 } |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 } | 262 } |
| 265 #ifdef DEBUG | 263 #ifdef DEBUG |
| 266 for (size_t index = 0; index < projection_count; ++index) { | 264 for (size_t index = 0; index < projection_count; ++index) { |
| 267 DCHECK_NOT_NULL(projections[index]); | 265 DCHECK_NOT_NULL(projections[index]); |
| 268 } | 266 } |
| 269 #endif | 267 #endif |
| 270 } | 268 } |
| 271 | 269 |
| 272 | 270 |
| 273 // static | 271 // 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 | |
| 319 bool NodeProperties::AllValueInputsAreTyped(Node* node) { | 272 bool NodeProperties::AllValueInputsAreTyped(Node* node) { |
| 320 int input_count = node->op()->ValueInputCount(); | 273 int input_count = node->op()->ValueInputCount(); |
| 321 for (int index = 0; index < input_count; ++index) { | 274 for (int index = 0; index < input_count; ++index) { |
| 322 if (!IsTyped(GetValueInput(node, index))) return false; | 275 if (!IsTyped(GetValueInput(node, index))) return false; |
| 323 } | 276 } |
| 324 return true; | 277 return true; |
| 325 } | 278 } |
| 326 | 279 |
| 327 | 280 |
| 328 // static | 281 // static |
| 329 bool NodeProperties::IsInputRange(Edge edge, int first, int num) { | 282 bool NodeProperties::IsInputRange(Edge edge, int first, int num) { |
| 330 if (num == 0) return false; | 283 if (num == 0) return false; |
| 331 int const index = edge.index(); | 284 int const index = edge.index(); |
| 332 return first <= index && index < first + num; | 285 return first <= index && index < first + num; |
| 333 } | 286 } |
| 334 | 287 |
| 335 } // namespace compiler | 288 } // namespace compiler |
| 336 } // namespace internal | 289 } // namespace internal |
| 337 } // namespace v8 | 290 } // namespace v8 |
| OLD | NEW |