Index: src/compiler/node.cc |
diff --git a/src/compiler/node.cc b/src/compiler/node.cc |
index 673ef3290e9127e8c2859a0b264485f59ebdd281..be635177871363901f5a147c7673adcb6df531ed 100644 |
--- a/src/compiler/node.cc |
+++ b/src/compiler/node.cc |
@@ -3,13 +3,56 @@ |
// found in the LICENSE file. |
#include "src/compiler/node.h" |
- |
-#include "src/compiler/generic-node-inl.h" |
+#include "src/compiler/graph.h" |
+#include "src/zone.h" |
namespace v8 { |
namespace internal { |
namespace compiler { |
+Node::Node(Graph* graph, int input_count, int reserve_input_count) |
+ : NodeData(graph->zone()), |
+ input_count_(input_count), |
+ reserve_input_count_(reserve_input_count), |
+ has_appendable_inputs_(false), |
+ use_count_(0), |
+ first_use_(NULL), |
+ last_use_(NULL) { |
+ DCHECK(reserve_input_count <= kMaxReservedInputs); |
+ inputs_.static_ = reinterpret_cast<Input*>(this + 1); |
+ id_ = graph->NextNodeID(); |
+} |
+ |
+ |
+Node* Node::New(Graph* graph, int input_count, Node** inputs, |
+ bool has_extensible_inputs) { |
+ size_t node_size = sizeof(Node); |
+ int reserve_input_count = has_extensible_inputs ? kDefaultReservedInputs : 0; |
+ size_t inputs_size = (input_count + reserve_input_count) * sizeof(Input); |
+ size_t uses_size = input_count * sizeof(Use); |
+ int size = static_cast<int>(node_size + inputs_size + uses_size); |
+ Zone* zone = graph->zone(); |
+ void* buffer = zone->New(size); |
+ Node* result = new (buffer) Node(graph, input_count, reserve_input_count); |
+ Input* input = |
+ reinterpret_cast<Input*>(reinterpret_cast<char*>(buffer) + node_size); |
+ Use* use = |
+ reinterpret_cast<Use*>(reinterpret_cast<char*>(input) + inputs_size); |
+ |
+ for (int current = 0; current < input_count; ++current) { |
+ Node* to = *inputs++; |
+ input->to = to; |
+ input->use = use; |
+ use->input_index = current; |
+ use->from = result; |
+ to->AppendUse(use); |
+ ++use; |
+ ++input; |
+ } |
+ return result; |
+} |
+ |
+ |
void Node::Kill() { |
DCHECK_NOT_NULL(op()); |
RemoveAllInputs(); |