Avoid usage of temporary MachineOperatorBuilder.
authormstarzinger@chromium.org <mstarzinger@chromium.org>
Tue, 16 Sep 2014 16:20:10 +0000 (16:20 +0000)
committermstarzinger@chromium.org <mstarzinger@chromium.org>
Tue, 16 Sep 2014 16:20:10 +0000 (16:20 +0000)
R=titzer@chromium.org

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

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@23982 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

16 files changed:
src/compiler/ast-graph-builder.cc
src/compiler/change-lowering-unittest.cc
src/compiler/change-lowering.cc
src/compiler/change-lowering.h
src/compiler/js-typed-lowering.h
src/compiler/machine-operator-reducer.cc
src/compiler/machine-operator-reducer.h
src/compiler/pipeline.cc
src/compiler/representation-change.h
src/compiler/simplified-lowering.cc
src/compiler/simplified-lowering.h
src/compiler/simplified-operator-reducer-unittest.cc
src/compiler/simplified-operator-reducer.cc
src/compiler/simplified-operator-reducer.h
test/cctest/compiler/test-changes-lowering.cc
test/cctest/compiler/test-representation-change.cc

index 1877a68..8d2a9bf 100644 (file)
@@ -1931,9 +1931,8 @@ Node* AstGraphBuilder::BuildVariableAssignment(Variable* variable, Node* value,
 
 Node* AstGraphBuilder::BuildLoadObjectField(Node* object, int offset) {
   // TODO(sigurds) Use simplified load here once it is ready.
-  MachineOperatorBuilder machine;
-  Node* field_load = NewNode(machine.Load(kMachAnyTagged), object,
-                             jsgraph_->Int32Constant(offset - kHeapObjectTag));
+  Node* field_load = NewNode(jsgraph()->machine()->Load(kMachAnyTagged), object,
+                             jsgraph()->Int32Constant(offset - kHeapObjectTag));
   return field_load;
 }
 
index 769198a..994027a 100644 (file)
@@ -79,7 +79,7 @@ class ChangeLoweringTest : public GraphTest {
     JSGraph jsgraph(graph(), common(), &javascript, &typer, &machine);
     CompilationInfo info(isolate(), zone());
     Linkage linkage(&info);
-    ChangeLowering reducer(&jsgraph, &linkage, &machine);
+    ChangeLowering reducer(&jsgraph, &linkage);
     return reducer.Reduce(node);
   }
 
index a885cf1..b13db4c 100644 (file)
@@ -246,6 +246,11 @@ CommonOperatorBuilder* ChangeLowering::common() const {
   return jsgraph()->common();
 }
 
+
+MachineOperatorBuilder* ChangeLowering::machine() const {
+  return jsgraph()->machine();
+}
+
 }  // namespace compiler
 }  // namespace internal
 }  // namespace v8
index 661d7bd..9f01feb 100644 (file)
@@ -19,9 +19,8 @@ class MachineOperatorBuilder;
 
 class ChangeLowering FINAL : public Reducer {
  public:
-  ChangeLowering(JSGraph* jsgraph, Linkage* linkage,
-                 MachineOperatorBuilder* machine)
-      : jsgraph_(jsgraph), linkage_(linkage), machine_(machine) {}
+  ChangeLowering(JSGraph* jsgraph, Linkage* linkage)
+      : jsgraph_(jsgraph), linkage_(linkage) {}
   virtual ~ChangeLowering();
 
   virtual Reduction Reduce(Node* node) OVERRIDE;
@@ -50,11 +49,10 @@ class ChangeLowering FINAL : public Reducer {
   JSGraph* jsgraph() const { return jsgraph_; }
   Linkage* linkage() const { return linkage_; }
   CommonOperatorBuilder* common() const;
-  MachineOperatorBuilder* machine() const { return machine_; }
+  MachineOperatorBuilder* machine() const;
 
   JSGraph* jsgraph_;
   Linkage* linkage_;
-  MachineOperatorBuilder* machine_;
 };
 
 }  // namespace compiler
index 4a10092..2700fcf 100644 (file)
@@ -51,11 +51,10 @@ class JSTypedLowering FINAL : public Reducer {
   JSOperatorBuilder* javascript() { return jsgraph_->javascript(); }
   CommonOperatorBuilder* common() { return jsgraph_->common(); }
   SimplifiedOperatorBuilder* simplified() { return &simplified_; }
-  MachineOperatorBuilder* machine() { return &machine_; }
+  MachineOperatorBuilder* machine() { return jsgraph_->machine(); }
 
   JSGraph* jsgraph_;
   SimplifiedOperatorBuilder simplified_;
-  MachineOperatorBuilder machine_;
 };
 
 }  // namespace compiler
index a873fa2..936deca 100644 (file)
@@ -477,6 +477,11 @@ CommonOperatorBuilder* MachineOperatorReducer::common() const {
 }
 
 
+MachineOperatorBuilder* MachineOperatorReducer::machine() const {
+  return jsgraph()->machine();
+}
+
+
 Graph* MachineOperatorReducer::graph() const { return jsgraph()->graph(); }
 
 }  // namespace compiler
index 509f5db..57fcdee 100644 (file)
@@ -47,10 +47,9 @@ class MachineOperatorReducer FINAL : public Reducer {
   Graph* graph() const;
   JSGraph* jsgraph() const { return jsgraph_; }
   CommonOperatorBuilder* common() const;
-  MachineOperatorBuilder* machine() { return &machine_; }
+  MachineOperatorBuilder* machine() const;
 
   JSGraph* jsgraph_;
-  MachineOperatorBuilder machine_;
 };
 
 }  // namespace compiler
index 5b6cf09..72f2093 100644 (file)
@@ -259,8 +259,8 @@ Handle<Code> Pipeline::GenerateCode() {
                                      SourcePosition::Unknown());
       Linkage linkage(info());
       ValueNumberingReducer vn_reducer(zone());
-      SimplifiedOperatorReducer simple_reducer(&jsgraph, &machine);
-      ChangeLowering lowering(&jsgraph, &linkage, &machine);
+      SimplifiedOperatorReducer simple_reducer(&jsgraph);
+      ChangeLowering lowering(&jsgraph, &linkage);
       MachineOperatorReducer mach_reducer(&jsgraph);
       GraphReducer graph_reducer(&graph);
       // TODO(titzer): Figure out if we should run all reducers at once here.
index 98bcbbf..3c6dcba 100644 (file)
@@ -21,10 +21,9 @@ namespace compiler {
 class RepresentationChanger {
  public:
   RepresentationChanger(JSGraph* jsgraph, SimplifiedOperatorBuilder* simplified,
-                        MachineOperatorBuilder* machine, Isolate* isolate)
+                        Isolate* isolate)
       : jsgraph_(jsgraph),
         simplified_(simplified),
-        machine_(machine),
         isolate_(isolate),
         testing_type_errors_(false),
         type_error_(false) {}
@@ -309,7 +308,6 @@ class RepresentationChanger {
  private:
   JSGraph* jsgraph_;
   SimplifiedOperatorBuilder* simplified_;
-  MachineOperatorBuilder* machine_;
   Isolate* isolate_;
 
   friend class RepresentationChangerTester;  // accesses the below fields.
@@ -339,7 +337,7 @@ class RepresentationChanger {
   JSGraph* jsgraph() { return jsgraph_; }
   Isolate* isolate() { return isolate_; }
   SimplifiedOperatorBuilder* simplified() { return simplified_; }
-  MachineOperatorBuilder* machine() { return machine_; }
+  MachineOperatorBuilder* machine() { return jsgraph()->machine(); }
 };
 }
 }
index 88cd125..d1f2ee3 100644 (file)
@@ -764,7 +764,7 @@ Node* SimplifiedLowering::IsTagged(Node* node) {
 
 void SimplifiedLowering::LowerAllNodes() {
   SimplifiedOperatorBuilder simplified(graph()->zone());
-  RepresentationChanger changer(jsgraph(), &simplified, machine(),
+  RepresentationChanger changer(jsgraph(), &simplified,
                                 graph()->zone()->isolate());
   RepresentationSelector selector(jsgraph(), zone(), &changer);
   selector.Run(this);
@@ -805,7 +805,7 @@ static WriteBarrierKind ComputeWriteBarrierKind(BaseTaggedness base_is_tagged,
 
 void SimplifiedLowering::DoLoadField(Node* node) {
   const FieldAccess& access = FieldAccessOf(node->op());
-  node->set_op(machine_.Load(access.machine_type));
+  node->set_op(machine()->Load(access.machine_type));
   Node* offset = jsgraph()->Int32Constant(access.offset - access.tag());
   node->InsertInput(zone(), 1, offset);
 }
@@ -815,7 +815,8 @@ void SimplifiedLowering::DoStoreField(Node* node) {
   const FieldAccess& access = FieldAccessOf(node->op());
   WriteBarrierKind kind = ComputeWriteBarrierKind(
       access.base_is_tagged, access.machine_type, access.type);
-  node->set_op(machine_.Store(StoreRepresentation(access.machine_type, kind)));
+  node->set_op(
+      machine()->Store(StoreRepresentation(access.machine_type, kind)));
   Node* offset = jsgraph()->Int32Constant(access.offset - access.tag());
   node->InsertInput(zone(), 1, offset);
 }
@@ -837,7 +838,7 @@ Node* SimplifiedLowering::ComputeIndex(const ElementAccess& access,
 
 void SimplifiedLowering::DoLoadElement(Node* node) {
   const ElementAccess& access = ElementAccessOf(node->op());
-  node->set_op(machine_.Load(access.machine_type));
+  node->set_op(machine()->Load(access.machine_type));
   node->ReplaceInput(1, ComputeIndex(access, node->InputAt(1)));
 }
 
@@ -846,7 +847,8 @@ void SimplifiedLowering::DoStoreElement(Node* node) {
   const ElementAccess& access = ElementAccessOf(node->op());
   WriteBarrierKind kind = ComputeWriteBarrierKind(
       access.base_is_tagged, access.machine_type, access.type);
-  node->set_op(machine_.Store(StoreRepresentation(access.machine_type, kind)));
+  node->set_op(
+      machine()->Store(StoreRepresentation(access.machine_type, kind)));
   node->ReplaceInput(1, ComputeIndex(access, node->InputAt(1)));
 }
 
index 9e83fdf..2ba7e3b 100644 (file)
@@ -33,7 +33,6 @@ class SimplifiedLowering {
 
  private:
   JSGraph* jsgraph_;
-  MachineOperatorBuilder machine_;
 
   Node* SmiTag(Node* node);
   Node* IsTagged(Node* node);
@@ -48,7 +47,7 @@ class SimplifiedLowering {
   JSGraph* jsgraph() { return jsgraph_; }
   Graph* graph() { return jsgraph()->graph(); }
   CommonOperatorBuilder* common() { return jsgraph()->common(); }
-  MachineOperatorBuilder* machine() { return &machine_; }
+  MachineOperatorBuilder* machine() { return jsgraph()->machine(); }
 };
 
 }  // namespace compiler
index c5744d3..739264e 100644 (file)
@@ -25,7 +25,7 @@ class SimplifiedOperatorReducerTest : public GraphTest {
     MachineOperatorBuilder machine;
     JSOperatorBuilder javascript(zone());
     JSGraph jsgraph(graph(), common(), &javascript, &typer, &machine);
-    SimplifiedOperatorReducer reducer(&jsgraph, &machine);
+    SimplifiedOperatorReducer reducer(&jsgraph);
     return reducer.Reduce(node);
   }
 
index 4dde248..f6181ea 100644 (file)
@@ -137,6 +137,11 @@ Factory* SimplifiedOperatorReducer::factory() const {
   return jsgraph()->isolate()->factory();
 }
 
+
+MachineOperatorBuilder* SimplifiedOperatorReducer::machine() const {
+  return jsgraph()->machine();
+}
+
 }  // namespace compiler
 }  // namespace internal
 }  // namespace v8
index 5932ed0..32f49ad 100644 (file)
@@ -21,8 +21,7 @@ class MachineOperatorBuilder;
 
 class SimplifiedOperatorReducer FINAL : public Reducer {
  public:
-  SimplifiedOperatorReducer(JSGraph* jsgraph, MachineOperatorBuilder* machine)
-      : jsgraph_(jsgraph), machine_(machine) {}
+  explicit SimplifiedOperatorReducer(JSGraph* jsgraph) : jsgraph_(jsgraph) {}
   virtual ~SimplifiedOperatorReducer();
 
   virtual Reduction Reduce(Node* node) OVERRIDE;
@@ -40,10 +39,9 @@ class SimplifiedOperatorReducer FINAL : public Reducer {
   Graph* graph() const;
   Factory* factory() const;
   JSGraph* jsgraph() const { return jsgraph_; }
-  MachineOperatorBuilder* machine() const { return machine_; }
+  MachineOperatorBuilder* machine() const;
 
   JSGraph* jsgraph_;
-  MachineOperatorBuilder* machine_;
 
   DISALLOW_COPY_AND_ASSIGN(SimplifiedOperatorReducer);
 };
index 63b2973..b91d583 100644 (file)
@@ -149,7 +149,7 @@ class ChangesLoweringTester : public GraphBuilderTester<ReturnType> {
     // Run the graph reducer with changes lowering on a single node.
     CompilationInfo info(this->isolate(), this->zone());
     Linkage linkage(&info);
-    ChangeLowering lowering(&jsgraph, &linkage, this->machine());
+    ChangeLowering lowering(&jsgraph, &linkage);
     GraphReducer reducer(this->graph());
     reducer.AddReducer(&lowering);
     reducer.ReduceNode(change);
index 36da572..9c55a80 100644 (file)
@@ -28,7 +28,7 @@ class RepresentationChangerTester : public HandleAndZoneScope,
         javascript_(main_zone()),
         jsgraph_(main_graph_, &main_common_, &javascript_, &typer_,
                  &main_machine_),
-        changer_(&jsgraph_, &main_simplified_, &main_machine_, main_isolate()) {
+        changer_(&jsgraph_, &main_simplified_, main_isolate()) {
     Node* s = graph()->NewNode(common()->Start(num_parameters));
     graph()->SetStart(s);
   }