Use phase-local zone in the graph builder.

R=jarin@chromium.org

Review URL: https://codereview.chromium.org/640423005

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@24531 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 3647fe80
...@@ -32,7 +32,7 @@ class ControlBuilder { ...@@ -32,7 +32,7 @@ class ControlBuilder {
typedef StructuredGraphBuilder Builder; typedef StructuredGraphBuilder Builder;
typedef StructuredGraphBuilder::Environment Environment; typedef StructuredGraphBuilder::Environment Environment;
Zone* zone() const { return builder_->zone(); } Zone* zone() const { return builder_->local_zone(); }
Environment* environment() { return builder_->environment(); } Environment* environment() { return builder_->environment(); }
void set_environment(Environment* env) { builder_->set_environment(env); } void set_environment(Environment* env) { builder_->set_environment(env); }
......
...@@ -24,6 +24,7 @@ StructuredGraphBuilder::StructuredGraphBuilder(Graph* graph, ...@@ -24,6 +24,7 @@ StructuredGraphBuilder::StructuredGraphBuilder(Graph* graph,
: GraphBuilder(graph), : GraphBuilder(graph),
common_(common), common_(common),
environment_(NULL), environment_(NULL),
local_zone_(isolate()),
current_context_(NULL), current_context_(NULL),
exit_control_(NULL) {} exit_control_(NULL) {}
...@@ -50,7 +51,7 @@ Node* StructuredGraphBuilder::MakeNode(const Operator* op, ...@@ -50,7 +51,7 @@ Node* StructuredGraphBuilder::MakeNode(const Operator* op,
if (has_framestate) ++input_count_with_deps; if (has_framestate) ++input_count_with_deps;
if (has_control) ++input_count_with_deps; if (has_control) ++input_count_with_deps;
if (has_effect) ++input_count_with_deps; if (has_effect) ++input_count_with_deps;
Node** buffer = zone()->NewArray<Node*>(input_count_with_deps); Node** buffer = local_zone()->NewArray<Node*>(input_count_with_deps);
memcpy(buffer, value_inputs, kPointerSize * value_input_count); memcpy(buffer, value_inputs, kPointerSize * value_input_count);
Node** current_input = buffer + value_input_count; Node** current_input = buffer + value_input_count;
if (has_context) { if (has_context) {
...@@ -95,7 +96,7 @@ void StructuredGraphBuilder::UpdateControlDependencyToLeaveFunction( ...@@ -95,7 +96,7 @@ void StructuredGraphBuilder::UpdateControlDependencyToLeaveFunction(
StructuredGraphBuilder::Environment* StructuredGraphBuilder::CopyEnvironment( StructuredGraphBuilder::Environment* StructuredGraphBuilder::CopyEnvironment(
Environment* env) { Environment* env) {
return new (zone()) Environment(*env); return new (local_zone()) Environment(*env);
} }
...@@ -163,7 +164,7 @@ void StructuredGraphBuilder::Environment::PrepareForLoop() { ...@@ -163,7 +164,7 @@ void StructuredGraphBuilder::Environment::PrepareForLoop() {
Node* StructuredGraphBuilder::NewPhi(int count, Node* input, Node* control) { Node* StructuredGraphBuilder::NewPhi(int count, Node* input, Node* control) {
const Operator* phi_op = common()->Phi(kMachAnyTagged, count); const Operator* phi_op = common()->Phi(kMachAnyTagged, count);
Node** buffer = zone()->NewArray<Node*>(count + 1); Node** buffer = local_zone()->NewArray<Node*>(count + 1);
MemsetPointer(buffer, input, count); MemsetPointer(buffer, input, count);
buffer[count] = control; buffer[count] = control;
return graph()->NewNode(phi_op, count + 1, buffer); return graph()->NewNode(phi_op, count + 1, buffer);
...@@ -174,7 +175,7 @@ Node* StructuredGraphBuilder::NewPhi(int count, Node* input, Node* control) { ...@@ -174,7 +175,7 @@ Node* StructuredGraphBuilder::NewPhi(int count, Node* input, Node* control) {
Node* StructuredGraphBuilder::NewEffectPhi(int count, Node* input, Node* StructuredGraphBuilder::NewEffectPhi(int count, Node* input,
Node* control) { Node* control) {
const Operator* phi_op = common()->EffectPhi(count); const Operator* phi_op = common()->EffectPhi(count);
Node** buffer = zone()->NewArray<Node*>(count + 1); Node** buffer = local_zone()->NewArray<Node*>(count + 1);
MemsetPointer(buffer, input, count); MemsetPointer(buffer, input, count);
buffer[count] = control; buffer[count] = control;
return graph()->NewNode(phi_op, count + 1, buffer); return graph()->NewNode(phi_op, count + 1, buffer);
...@@ -186,12 +187,12 @@ Node* StructuredGraphBuilder::MergeControl(Node* control, Node* other) { ...@@ -186,12 +187,12 @@ Node* StructuredGraphBuilder::MergeControl(Node* control, Node* other) {
if (control->opcode() == IrOpcode::kLoop) { if (control->opcode() == IrOpcode::kLoop) {
// Control node for loop exists, add input. // Control node for loop exists, add input.
const Operator* op = common()->Loop(inputs); const Operator* op = common()->Loop(inputs);
control->AppendInput(zone(), other); control->AppendInput(graph_zone(), other);
control->set_op(op); control->set_op(op);
} else if (control->opcode() == IrOpcode::kMerge) { } else if (control->opcode() == IrOpcode::kMerge) {
// Control node for merge exists, add input. // Control node for merge exists, add input.
const Operator* op = common()->Merge(inputs); const Operator* op = common()->Merge(inputs);
control->AppendInput(zone(), other); control->AppendInput(graph_zone(), other);
control->set_op(op); control->set_op(op);
} else { } else {
// Control node is a singleton, introduce a merge. // Control node is a singleton, introduce a merge.
...@@ -209,7 +210,7 @@ Node* StructuredGraphBuilder::MergeEffect(Node* value, Node* other, ...@@ -209,7 +210,7 @@ Node* StructuredGraphBuilder::MergeEffect(Node* value, Node* other,
NodeProperties::GetControlInput(value) == control) { NodeProperties::GetControlInput(value) == control) {
// Phi already exists, add input. // Phi already exists, add input.
value->set_op(common()->EffectPhi(inputs)); value->set_op(common()->EffectPhi(inputs));
value->InsertInput(zone(), inputs - 1, other); value->InsertInput(graph_zone(), inputs - 1, other);
} else if (value != other) { } else if (value != other) {
// Phi does not exist yet, introduce one. // Phi does not exist yet, introduce one.
value = NewEffectPhi(inputs, value, control); value = NewEffectPhi(inputs, value, control);
...@@ -226,7 +227,7 @@ Node* StructuredGraphBuilder::MergeValue(Node* value, Node* other, ...@@ -226,7 +227,7 @@ Node* StructuredGraphBuilder::MergeValue(Node* value, Node* other,
NodeProperties::GetControlInput(value) == control) { NodeProperties::GetControlInput(value) == control) {
// Phi already exists, add input. // Phi already exists, add input.
value->set_op(common()->Phi(kMachAnyTagged, inputs)); value->set_op(common()->Phi(kMachAnyTagged, inputs));
value->InsertInput(zone(), inputs - 1, other); value->InsertInput(graph_zone(), inputs - 1, other);
} else if (value != other) { } else if (value != other) {
// Phi does not exist yet, introduce one. // Phi does not exist yet, introduce one.
value = NewPhi(inputs, value, control); value = NewPhi(inputs, value, control);
......
...@@ -122,9 +122,9 @@ class StructuredGraphBuilder : public GraphBuilder { ...@@ -122,9 +122,9 @@ class StructuredGraphBuilder : public GraphBuilder {
Node* dead_control(); Node* dead_control();
// TODO(mstarzinger): Use phase-local zone instead! Zone* graph_zone() const { return graph()->zone(); }
Zone* zone() const { return graph()->zone(); } Zone* local_zone() { return &local_zone_; }
Isolate* isolate() const { return zone()->isolate(); } Isolate* isolate() const { return graph_zone()->isolate(); }
CommonOperatorBuilder* common() const { return common_; } CommonOperatorBuilder* common() const { return common_; }
// Helper to wrap a Handle<T> into a Unique<T>. // Helper to wrap a Handle<T> into a Unique<T>.
...@@ -144,6 +144,9 @@ class StructuredGraphBuilder : public GraphBuilder { ...@@ -144,6 +144,9 @@ class StructuredGraphBuilder : public GraphBuilder {
CommonOperatorBuilder* common_; CommonOperatorBuilder* common_;
Environment* environment_; Environment* environment_;
// Zone local to the builder for data not leaking into the graph.
Zone local_zone_;
// Node representing the control dependency for dead code. // Node representing the control dependency for dead code.
SetOncePointer<Node> dead_control_; SetOncePointer<Node> dead_control_;
...@@ -207,8 +210,7 @@ class StructuredGraphBuilder::Environment : public ZoneObject { ...@@ -207,8 +210,7 @@ class StructuredGraphBuilder::Environment : public ZoneObject {
Node* GetContext() { return builder_->current_context(); } Node* GetContext() { return builder_->current_context(); }
protected: protected:
// TODO(mstarzinger): Use phase-local zone instead! Zone* zone() const { return builder_->local_zone(); }
Zone* zone() const { return graph()->zone(); }
Graph* graph() const { return builder_->graph(); } Graph* graph() const { return builder_->graph(); }
StructuredGraphBuilder* builder() const { return builder_; } StructuredGraphBuilder* builder() const { return builder_; }
CommonOperatorBuilder* common() { return builder_->common(); } CommonOperatorBuilder* common() { return builder_->common(); }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment