Reviewers: jarin,

Description:
Use phase-local zone in the graph builder.

[email protected]

Please review this at https://codereview.chromium.org/640423005/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files (+17, -14 lines):
  M src/compiler/control-builders.h
  M src/compiler/graph-builder.h
  M src/compiler/graph-builder.cc


Index: src/compiler/control-builders.h
diff --git a/src/compiler/control-builders.h b/src/compiler/control-builders.h index 695282be8aab0901a3d252ba70aa95b4a634d3d6..eb674bf018ac6e87d77f6c72aec31e524802fe3a 100644
--- a/src/compiler/control-builders.h
+++ b/src/compiler/control-builders.h
@@ -32,7 +32,7 @@ class ControlBuilder {
   typedef StructuredGraphBuilder Builder;
   typedef StructuredGraphBuilder::Environment Environment;

-  Zone* zone() const { return builder_->zone(); }
+  Zone* zone() const { return builder_->local_zone(); }
   Environment* environment() { return builder_->environment(); }
void set_environment(Environment* env) { builder_->set_environment(env); }

Index: src/compiler/graph-builder.cc
diff --git a/src/compiler/graph-builder.cc b/src/compiler/graph-builder.cc
index 899288159848f7cacaa52d7d774284c139ba8b1c..b50d02875f216fb089f8cbab10406e193555a88a 100644
--- a/src/compiler/graph-builder.cc
+++ b/src/compiler/graph-builder.cc
@@ -24,6 +24,7 @@ StructuredGraphBuilder::StructuredGraphBuilder(Graph* graph,
     : GraphBuilder(graph),
       common_(common),
       environment_(NULL),
+      local_zone_(isolate()),
       current_context_(NULL),
       exit_control_(NULL) {}

@@ -50,7 +51,7 @@ Node* StructuredGraphBuilder::MakeNode(const Operator* op,
     if (has_framestate) ++input_count_with_deps;
     if (has_control) ++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);
     Node** current_input = buffer + value_input_count;
     if (has_context) {
@@ -95,7 +96,7 @@ void StructuredGraphBuilder::UpdateControlDependencyToLeaveFunction(

StructuredGraphBuilder::Environment* StructuredGraphBuilder::CopyEnvironment(
     Environment* env) {
-  return new (zone()) Environment(*env);
+  return new (local_zone()) Environment(*env);
 }


@@ -163,7 +164,7 @@ void StructuredGraphBuilder::Environment::PrepareForLoop() {

Node* StructuredGraphBuilder::NewPhi(int count, Node* input, Node* control) {
   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);
   buffer[count] = control;
   return graph()->NewNode(phi_op, count + 1, buffer);
@@ -174,7 +175,7 @@ Node* StructuredGraphBuilder::NewPhi(int count, Node* input, Node* control) {
 Node* StructuredGraphBuilder::NewEffectPhi(int count, Node* input,
                                            Node* control) {
   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);
   buffer[count] = control;
   return graph()->NewNode(phi_op, count + 1, buffer);
@@ -186,12 +187,12 @@ Node* StructuredGraphBuilder::MergeControl(Node* control, Node* other) {
   if (control->opcode() == IrOpcode::kLoop) {
     // Control node for loop exists, add input.
     const Operator* op = common()->Loop(inputs);
-    control->AppendInput(zone(), other);
+    control->AppendInput(graph_zone(), other);
     control->set_op(op);
   } else if (control->opcode() == IrOpcode::kMerge) {
     // Control node for merge exists, add input.
     const Operator* op = common()->Merge(inputs);
-    control->AppendInput(zone(), other);
+    control->AppendInput(graph_zone(), other);
     control->set_op(op);
   } else {
     // Control node is a singleton, introduce a merge.
@@ -209,7 +210,7 @@ Node* StructuredGraphBuilder::MergeEffect(Node* value, Node* other,
       NodeProperties::GetControlInput(value) == control) {
     // Phi already exists, add input.
     value->set_op(common()->EffectPhi(inputs));
-    value->InsertInput(zone(), inputs - 1, other);
+    value->InsertInput(graph_zone(), inputs - 1, other);
   } else if (value != other) {
     // Phi does not exist yet, introduce one.
     value = NewEffectPhi(inputs, value, control);
@@ -226,7 +227,7 @@ Node* StructuredGraphBuilder::MergeValue(Node* value, Node* other,
       NodeProperties::GetControlInput(value) == control) {
     // Phi already exists, add input.
     value->set_op(common()->Phi(kMachAnyTagged, inputs));
-    value->InsertInput(zone(), inputs - 1, other);
+    value->InsertInput(graph_zone(), inputs - 1, other);
   } else if (value != other) {
     // Phi does not exist yet, introduce one.
     value = NewPhi(inputs, value, control);
Index: src/compiler/graph-builder.h
diff --git a/src/compiler/graph-builder.h b/src/compiler/graph-builder.h
index c966c299b98265be53a59a46569892b11debe0be..95e09bbfaf5820bef502986895ec4be5a9e38d6d 100644
--- a/src/compiler/graph-builder.h
+++ b/src/compiler/graph-builder.h
@@ -122,9 +122,9 @@ class StructuredGraphBuilder : public GraphBuilder {

   Node* dead_control();

-  // TODO(mstarzinger): Use phase-local zone instead!
-  Zone* zone() const { return graph()->zone(); }
-  Isolate* isolate() const { return zone()->isolate(); }
+  Zone* graph_zone() const { return graph()->zone(); }
+  Zone* local_zone() { return &local_zone_; }
+  Isolate* isolate() const { return graph_zone()->isolate(); }
   CommonOperatorBuilder* common() const { return common_; }

   // Helper to wrap a Handle<T> into a Unique<T>.
@@ -144,6 +144,9 @@ class StructuredGraphBuilder : public GraphBuilder {
   CommonOperatorBuilder* common_;
   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.
   SetOncePointer<Node> dead_control_;

@@ -207,8 +210,7 @@ class StructuredGraphBuilder::Environment : public ZoneObject {
   Node* GetContext() { return builder_->current_context(); }

  protected:
-  // TODO(mstarzinger): Use phase-local zone instead!
-  Zone* zone() const { return graph()->zone(); }
+  Zone* zone() const { return builder_->local_zone(); }
   Graph* graph() const { return builder_->graph(); }
   StructuredGraphBuilder* builder() const { return builder_; }
   CommonOperatorBuilder* common() { return builder_->common(); }


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to