}
+Node* Graph::CloneNode(const Node* node) {
+ DCHECK_NOT_NULL(node);
+ Node* const clone = Node::Clone(zone(), NextNodeId(), node);
+ Decorate(clone);
+ return clone;
+}
+
+
NodeId Graph::NextNodeId() {
NodeId const id = next_node_id_;
CHECK(!base::bits::UnsignedAddOverflow32(id, 1, &next_node_id_));
return NewNode(op, arraysize(nodes), nodes);
}
+ // Clone the {node}, and assign a new node id to the copy.
+ Node* CloneNode(const Node* node);
+
template <class Visitor>
inline void VisitNodeInputsFromEnd(Visitor* visitor);
Node* Node::New(Zone* zone, NodeId id, const Operator* op, int input_count,
- Node** inputs, bool has_extensible_inputs) {
+ Node* const* inputs, bool has_extensible_inputs) {
Node** input_ptr;
Use* use_ptr;
Node* node;
}
+Node* Node::Clone(Zone* zone, NodeId id, const Node* node) {
+ int const input_count = node->InputCount();
+ Node* const* const inputs = node->has_inline_inputs()
+ ? node->inputs_.inline_
+ : node->inputs_.outline_->inputs_;
+ Node* const clone = New(zone, id, node->op(), input_count, inputs, false);
+ clone->set_bounds(node->bounds());
+ return clone;
+}
+
+
void Node::Kill() {
DCHECK_NOT_NULL(op());
NullAllInputs();
class Node final {
public:
static Node* New(Zone* zone, NodeId id, const Operator* op, int input_count,
- Node** inputs, bool has_extensible_inputs);
+ Node* const* inputs, bool has_extensible_inputs);
+ static Node* Clone(Zone* zone, NodeId id, const Node* node);
bool IsDead() const { return InputCount() > 0 && !InputAt(0); }
void Kill();
void* operator new(size_t, void* location) { return location; }
// Only NodeProperties should manipulate the bounds.
- Bounds bounds() { return bounds_; }
+ Bounds bounds() const { return bounds_; }
void set_bounds(Bounds b) { bounds_ = b; }
// Only NodeMarkers should manipulate the marks on nodes.
Node* CloneNode(Node* node) {
int const input_count = node->InputCount();
- Node** const inputs = scheduler_->zone_->NewArray<Node*>(input_count);
for (int index = 0; index < input_count; ++index) {
Node* const input = node->InputAt(index);
scheduler_->IncrementUnscheduledUseCount(input, index, node);
- inputs[index] = input;
}
- Node* copy = scheduler_->graph_->NewNode(node->op(), input_count, inputs);
+ Node* const copy = scheduler_->graph_->CloneNode(node);
TRACE(("clone #%d:%s -> #%d\n"), node->id(), node->op()->mnemonic(),
copy->id());
scheduler_->node_data_.resize(copy->id() + 1,