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