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