| 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 "src/compiler/common-operator.h" | 7 #include "src/compiler/common-operator.h" |
| 8 #include "src/compiler/generic-node-inl.h" | 8 #include "src/compiler/generic-node-inl.h" |
| 9 #include "src/compiler/graph-inl.h" | 9 #include "src/compiler/graph-inl.h" |
| 10 #include "src/compiler/node.h" | 10 #include "src/compiler/node.h" |
| 11 #include "src/compiler/node-aux-data-inl.h" | 11 #include "src/compiler/node-aux-data-inl.h" |
| 12 #include "src/compiler/node-properties.h" | 12 #include "src/compiler/node-properties.h" |
| 13 #include "src/compiler/node-properties-inl.h" | 13 #include "src/compiler/node-properties-inl.h" |
| 14 #include "src/compiler/operator-properties.h" | 14 #include "src/compiler/operator-properties.h" |
| 15 #include "src/compiler/operator-properties-inl.h" | 15 #include "src/compiler/operator-properties-inl.h" |
| 16 | 16 |
| 17 namespace v8 { | 17 namespace v8 { |
| 18 namespace internal { | 18 namespace internal { |
| 19 namespace compiler { | 19 namespace compiler { |
| 20 | 20 |
| 21 Graph::Graph(Zone* zone) | 21 Graph::Graph(Zone* zone) |
| 22 : GenericGraph<Node>(zone), | 22 : GenericGraph<Node>(zone), |
| 23 decorators_(DecoratorVector::allocator_type(zone)) {} | 23 decorators_(DecoratorVector::allocator_type(zone)), |
| 24 is_typed_(false) {} |
| 25 |
| 26 |
| 27 void Graph::Decorate(Node* node) { |
| 28 for (DecoratorVector::iterator i = decorators_.begin(); |
| 29 i != decorators_.end(); ++i) { |
| 30 (*i)->Decorate(node); |
| 31 } |
| 32 // Iff the graph is typed, then there _must_ be a decorator to type new nodes. |
| 33 DCHECK(NodeProperties::IsTyped(node) == |
| 34 (is_typed_ && OperatorProperties::HasValueOutput(node->op()))); |
| 35 } |
| 24 | 36 |
| 25 | 37 |
| 26 Node* Graph::NewNode(Operator* op, int input_count, Node** inputs) { | 38 Node* Graph::NewNode(Operator* op, int input_count, Node** inputs) { |
| 27 DCHECK(op->InputCount() <= input_count); | 39 DCHECK(op->InputCount() <= input_count); |
| 28 Node* result = Node::New(this, input_count, inputs); | 40 Node* result = Node::New(this, input_count, inputs); |
| 29 result->Initialize(op); | 41 result->Initialize(op); |
| 30 for (DecoratorVector::iterator i = decorators_.begin(); | 42 Decorate(result); |
| 31 i != decorators_.end(); ++i) { | |
| 32 (*i)->Decorate(result); | |
| 33 } | |
| 34 return result; | 43 return result; |
| 35 } | 44 } |
| 36 | 45 |
| 37 | 46 |
| 38 void Graph::ChangeOperator(Node* node, Operator* op) { node->set_op(op); } | 47 void Graph::ChangeOperator(Node* node, Operator* op) { node->set_op(op); } |
| 39 | 48 |
| 40 | 49 |
| 41 void Graph::DeleteNode(Node* node) { | 50 void Graph::DeleteNode(Node* node) { |
| 42 #if DEBUG | 51 #if DEBUG |
| 43 // Nodes can't be deleted if they have uses. | 52 // Nodes can't be deleted if they have uses. |
| 44 Node::Uses::iterator use_iterator(node->uses().begin()); | 53 Node::Uses::iterator use_iterator(node->uses().begin()); |
| 45 DCHECK(use_iterator == node->uses().end()); | 54 DCHECK(use_iterator == node->uses().end()); |
| 46 #endif | 55 #endif |
| 47 | 56 |
| 48 #if DEBUG | 57 #if DEBUG |
| 49 memset(node, 0xDE, sizeof(Node)); | 58 memset(node, 0xDE, sizeof(Node)); |
| 50 #endif | 59 #endif |
| 51 } | 60 } |
| 52 } | 61 } |
| 53 } | 62 } |
| 54 } // namespace v8::internal::compiler | 63 } // namespace v8::internal::compiler |
| OLD | NEW |