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/graph.h" | 5 #include "src/compiler/graph.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
10 #include "src/compiler/node.h" | 10 #include "src/compiler/node.h" |
11 #include "src/compiler/operator-properties.h" | 11 #include "src/compiler/node-properties.h" |
12 | 12 |
13 namespace v8 { | 13 namespace v8 { |
14 namespace internal { | 14 namespace internal { |
15 namespace compiler { | 15 namespace compiler { |
16 | 16 |
17 Graph::Graph(Zone* zone) | 17 Graph::Graph(Zone* zone) |
18 : zone_(zone), | 18 : zone_(zone), |
19 start_(nullptr), | 19 start_(nullptr), |
20 end_(nullptr), | 20 end_(nullptr), |
21 mark_max_(0), | 21 mark_max_(0), |
(...skipping 15 matching lines...) Expand all Loading... |
37 | 37 |
38 void Graph::RemoveDecorator(GraphDecorator* decorator) { | 38 void Graph::RemoveDecorator(GraphDecorator* decorator) { |
39 auto const it = std::find(decorators_.begin(), decorators_.end(), decorator); | 39 auto const it = std::find(decorators_.begin(), decorators_.end(), decorator); |
40 DCHECK(it != decorators_.end()); | 40 DCHECK(it != decorators_.end()); |
41 decorators_.erase(it); | 41 decorators_.erase(it); |
42 } | 42 } |
43 | 43 |
44 | 44 |
45 Node* Graph::NewNode(const Operator* op, int input_count, Node** inputs, | 45 Node* Graph::NewNode(const Operator* op, int input_count, Node** inputs, |
46 bool incomplete) { | 46 bool incomplete) { |
47 DCHECK_EQ(OperatorProperties::GetTotalInputCount(op), input_count); | 47 Node* node = NewNodeUnchecked(op, input_count, inputs, incomplete); |
48 return NewNodeUnchecked(op, input_count, inputs, incomplete); | 48 #ifdef DEBUG |
| 49 NodeProperties::Verify(node); |
| 50 #endif // DEBUG |
| 51 return node; |
49 } | 52 } |
50 | 53 |
51 | 54 |
52 Node* Graph::NewNodeUnchecked(const Operator* op, int input_count, | 55 Node* Graph::NewNodeUnchecked(const Operator* op, int input_count, |
53 Node** inputs, bool incomplete) { | 56 Node** inputs, bool incomplete) { |
54 Node* const node = | 57 Node* const node = |
55 Node::New(zone(), NextNodeId(), op, input_count, inputs, incomplete); | 58 Node::New(zone(), NextNodeId(), op, input_count, inputs, incomplete); |
56 Decorate(node); | 59 Decorate(node); |
57 return node; | 60 return node; |
58 } | 61 } |
59 | 62 |
60 | 63 |
61 Node* Graph::CloneNode(const Node* node) { | 64 Node* Graph::CloneNode(const Node* node) { |
62 DCHECK_NOT_NULL(node); | 65 DCHECK_NOT_NULL(node); |
63 Node* const clone = Node::Clone(zone(), NextNodeId(), node); | 66 Node* const clone = Node::Clone(zone(), NextNodeId(), node); |
64 Decorate(clone); | 67 Decorate(clone); |
65 return clone; | 68 return clone; |
66 } | 69 } |
67 | 70 |
68 | 71 |
69 NodeId Graph::NextNodeId() { | 72 NodeId Graph::NextNodeId() { |
70 NodeId const id = next_node_id_; | 73 NodeId const id = next_node_id_; |
71 CHECK(!base::bits::UnsignedAddOverflow32(id, 1, &next_node_id_)); | 74 CHECK(!base::bits::UnsignedAddOverflow32(id, 1, &next_node_id_)); |
72 return id; | 75 return id; |
73 } | 76 } |
74 | 77 |
75 } // namespace compiler | 78 } // namespace compiler |
76 } // namespace internal | 79 } // namespace internal |
77 } // namespace v8 | 80 } // namespace v8 |
OLD | NEW |