Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 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/graph.h" |
| 6 | |
| 7 | #include "src/compiler/common-operator.h" |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 8 | #include "src/compiler/graph-inl.h" |
| 9 | #include "src/compiler/node.h" |
| 10 | #include "src/compiler/node-aux-data-inl.h" |
| 11 | #include "src/compiler/node-properties.h" |
| 12 | #include "src/compiler/node-properties-inl.h" |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 13 | #include "src/compiler/opcodes.h" |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 14 | #include "src/compiler/operator-properties.h" |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 15 | |
| 16 | namespace v8 { |
| 17 | namespace internal { |
| 18 | namespace compiler { |
| 19 | |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 20 | Graph::Graph(Zone* zone) |
| 21 | : zone_(zone), |
| 22 | start_(NULL), |
| 23 | end_(NULL), |
| 24 | mark_max_(0), |
| 25 | next_node_id_(0), |
| 26 | decorators_(zone) {} |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 27 | |
| 28 | |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 29 | void Graph::Decorate(Node* node) { |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 30 | for (ZoneVector<GraphDecorator*>::iterator i = decorators_.begin(); |
| 31 | i != decorators_.end(); ++i) { |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 32 | (*i)->Decorate(node); |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | |
| 37 | Node* Graph::NewNode(const Operator* op, int input_count, Node** inputs, |
| 38 | bool incomplete) { |
| 39 | DCHECK_LE(op->ValueInputCount(), input_count); |
| 40 | Node* result = Node::New(this, input_count, inputs, incomplete); |
| 41 | result->Initialize(op); |
| 42 | if (!incomplete) { |
| 43 | Decorate(result); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 44 | } |
| 45 | return result; |
| 46 | } |
| 47 | |
| 48 | } // namespace compiler |
| 49 | } // namespace internal |
| 50 | } // namespace v8 |