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