| 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 #include "src/compiler/node.h" | 5 #include "src/compiler/node.h" |
| 6 | 6 |
| 7 #include "src/compiler/generic-node-inl.h" | 7 #include "src/compiler/generic-node-inl.h" |
| 8 | 8 |
| 9 namespace v8 { | 9 namespace v8 { |
| 10 namespace internal { | 10 namespace internal { |
| 11 namespace compiler { | 11 namespace compiler { |
| 12 | 12 |
| 13 void Node::Kill() { | 13 void Node::Kill() { |
| 14 DCHECK_NOT_NULL(op()); | 14 DCHECK_NOT_NULL(op()); |
| 15 RemoveAllInputs(); | 15 RemoveAllInputs(); |
| 16 DCHECK(uses().empty()); | 16 DCHECK(uses().empty()); |
| 17 } | 17 } |
| 18 | 18 |
| 19 | 19 |
| 20 void Node::CollectProjections(NodeVector* projections) { | 20 void Node::CollectProjections(NodeVector* projections) { |
| 21 for (size_t i = 0; i < projections->size(); i++) { | 21 for (size_t i = 0; i < projections->size(); i++) { |
| 22 (*projections)[i] = NULL; | 22 (*projections)[i] = NULL; |
| 23 } | 23 } |
| 24 for (UseIter i = uses().begin(); i != uses().end(); ++i) { | 24 for (UseIter i = uses().begin(); i != uses().end(); ++i) { |
| 25 if ((*i)->opcode() != IrOpcode::kProjection) continue; | 25 if ((*i)->opcode() != IrOpcode::kProjection) continue; |
| 26 int32_t index = OpParameter<int32_t>(*i); | 26 size_t index = OpParameter<size_t>(*i); |
| 27 DCHECK_GE(index, 0); | 27 DCHECK_LT(index, projections->size()); |
| 28 DCHECK_LT(index, static_cast<int32_t>(projections->size())); | |
| 29 DCHECK_EQ(NULL, (*projections)[index]); | 28 DCHECK_EQ(NULL, (*projections)[index]); |
| 30 (*projections)[index] = *i; | 29 (*projections)[index] = *i; |
| 31 } | 30 } |
| 32 } | 31 } |
| 33 | 32 |
| 34 | 33 |
| 35 Node* Node::FindProjection(int32_t projection_index) { | 34 Node* Node::FindProjection(size_t projection_index) { |
| 36 for (UseIter i = uses().begin(); i != uses().end(); ++i) { | 35 for (UseIter i = uses().begin(); i != uses().end(); ++i) { |
| 37 if ((*i)->opcode() == IrOpcode::kProjection && | 36 if ((*i)->opcode() == IrOpcode::kProjection && |
| 38 OpParameter<int32_t>(*i) == projection_index) { | 37 OpParameter<size_t>(*i) == projection_index) { |
| 39 return *i; | 38 return *i; |
| 40 } | 39 } |
| 41 } | 40 } |
| 42 return NULL; | 41 return NULL; |
| 43 } | 42 } |
| 44 | 43 |
| 45 | 44 |
| 46 OStream& operator<<(OStream& os, const Operator& op) { return op.PrintTo(os); } | 45 OStream& operator<<(OStream& os, const Operator& op) { return op.PrintTo(os); } |
| 47 | 46 |
| 48 | 47 |
| 49 OStream& operator<<(OStream& os, const Node& n) { | 48 OStream& operator<<(OStream& os, const Node& n) { |
| 50 os << n.id() << ": " << *n.op(); | 49 os << n.id() << ": " << *n.op(); |
| 51 if (n.op()->InputCount() != 0) { | 50 if (n.op()->InputCount() != 0) { |
| 52 os << "("; | 51 os << "("; |
| 53 for (int i = 0; i < n.op()->InputCount(); ++i) { | 52 for (int i = 0; i < n.op()->InputCount(); ++i) { |
| 54 if (i != 0) os << ", "; | 53 if (i != 0) os << ", "; |
| 55 os << n.InputAt(i)->id(); | 54 os << n.InputAt(i)->id(); |
| 56 } | 55 } |
| 57 os << ")"; | 56 os << ")"; |
| 58 } | 57 } |
| 59 return os; | 58 return os; |
| 60 } | 59 } |
| 61 | 60 |
| 62 } // namespace compiler | 61 } // namespace compiler |
| 63 } // namespace internal | 62 } // namespace internal |
| 64 } // namespace v8 | 63 } // namespace v8 |
| OLD | NEW |