Revision: 23128
Author:   mstarzin...@chromium.org
Date:     Thu Aug 14 12:24:37 2014 UTC
Log:      Deprecate LoweringBuilder in favor of Reducer.

R=bmeu...@chromium.org

Review URL: https://codereview.chromium.org/476733002
http://code.google.com/p/v8/source/detail?r=23128

Deleted:
 /branches/bleeding_edge/src/compiler/lowering-builder.cc
 /branches/bleeding_edge/src/compiler/lowering-builder.h
Modified:
 /branches/bleeding_edge/BUILD.gn
 /branches/bleeding_edge/src/compiler/js-generic-lowering.cc
 /branches/bleeding_edge/src/compiler/js-generic-lowering.h
 /branches/bleeding_edge/src/compiler/js-typed-lowering.h
 /branches/bleeding_edge/src/compiler/pipeline.cc
 /branches/bleeding_edge/src/compiler/simplified-lowering.cc
 /branches/bleeding_edge/src/compiler/simplified-lowering.h
 /branches/bleeding_edge/test/cctest/compiler/test-changes-lowering.cc
 /branches/bleeding_edge/test/cctest/compiler/test-js-typed-lowering.cc
 /branches/bleeding_edge/test/cctest/compiler/test-simplified-lowering.cc
 /branches/bleeding_edge/tools/gyp/v8.gyp

=======================================
--- /branches/bleeding_edge/src/compiler/lowering-builder.cc Mon Aug 11 09:40:02 2014 UTC
+++ /dev/null
@@ -1,45 +0,0 @@
-// Copyright 2014 the V8 project authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "src/compiler/graph-inl.h"
-#include "src/compiler/lowering-builder.h"
-#include "src/compiler/node-aux-data-inl.h"
-#include "src/compiler/node-properties-inl.h"
-
-namespace v8 {
-namespace internal {
-namespace compiler {
-
-class LoweringBuilder::NodeVisitor : public NullNodeVisitor {
- public:
-  explicit NodeVisitor(LoweringBuilder* lowering) : lowering_(lowering) {}
-
-  GenericGraphVisit::Control Post(Node* node) {
-    if (lowering_->source_positions_ != NULL) {
-      SourcePositionTable::Scope pos(lowering_->source_positions_, node);
-      lowering_->Lower(node);
-    } else {
-      lowering_->Lower(node);
-    }
-    return GenericGraphVisit::CONTINUE;
-  }
-
- private:
-  LoweringBuilder* lowering_;
-};
-
-
-LoweringBuilder::LoweringBuilder(Graph* graph,
-                                 SourcePositionTable* source_positions)
-    : graph_(graph), source_positions_(source_positions) {}
-
-
-void LoweringBuilder::LowerAllNodes() {
-  NodeVisitor visitor(this);
-  graph()->VisitNodeInputsFromEnd(&visitor);
-}
-
-}  // namespace compiler
-}  // namespace internal
-}  // namespace v8
=======================================
--- /branches/bleeding_edge/src/compiler/lowering-builder.h Wed Jul 30 13:54:45 2014 UTC
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright 2014 the V8 project authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef V8_COMPILER_LOWERING_BUILDER_H_
-#define V8_COMPILER_LOWERING_BUILDER_H_
-
-#include "src/v8.h"
-
-#include "src/compiler/graph.h"
-
-
-namespace v8 {
-namespace internal {
-namespace compiler {
-
-// TODO(dcarney): rename this class.
-class LoweringBuilder {
- public:
- explicit LoweringBuilder(Graph* graph, SourcePositionTable* source_positions);
-  virtual ~LoweringBuilder() {}
-
-  void LowerAllNodes();
-  virtual void Lower(Node* node) = 0;  // Exposed for testing.
-
-  Graph* graph() const { return graph_; }
-
- private:
-  class NodeVisitor;
-  Graph* graph_;
-  SourcePositionTable* source_positions_;
-};
-
-}  // namespace compiler
-}  // namespace internal
-}  // namespace v8
-
-#endif  // V8_COMPILER_LOWERING_BUILDER_H_
=======================================
--- /branches/bleeding_edge/BUILD.gn    Thu Aug 14 09:07:58 2014 UTC
+++ /branches/bleeding_edge/BUILD.gn    Thu Aug 14 12:24:37 2014 UTC
@@ -505,8 +505,6 @@
     "src/compiler/linkage-impl.h",
     "src/compiler/linkage.cc",
     "src/compiler/linkage.h",
-    "src/compiler/lowering-builder.cc",
-    "src/compiler/lowering-builder.h",
     "src/compiler/machine-node-factory.h",
     "src/compiler/machine-operator-reducer.cc",
     "src/compiler/machine-operator-reducer.h",
=======================================
--- /branches/bleeding_edge/src/compiler/js-generic-lowering.cc Thu Aug 14 09:19:54 2014 UTC +++ /branches/bleeding_edge/src/compiler/js-generic-lowering.cc Thu Aug 14 12:24:37 2014 UTC
@@ -156,10 +156,8 @@


JSGenericLowering::JSGenericLowering(CompilationInfo* info, JSGraph* jsgraph,
-                                     MachineOperatorBuilder* machine,
-                                     SourcePositionTable* source_positions)
-    : LoweringBuilder(jsgraph->graph(), source_positions),
-      info_(info),
+                                     MachineOperatorBuilder* machine)
+    : info_(info),
       jsgraph_(jsgraph),
       linkage_(new (jsgraph->zone()) Linkage(info)),
       machine_(machine) {}
@@ -200,7 +198,7 @@
 }


-void JSGenericLowering::Lower(Node* node) {
+Reduction JSGenericLowering::Reduce(Node* node) {
   Node* replacement = NULL;
   // Dispatch according to the opcode.
   switch (node->opcode()) {
@@ -213,14 +211,10 @@
 #undef DECLARE_CASE
     default:
       // Nothing to see.
-      return;
+      return NoChange();
   }
-
-  // Nothing to do if lowering was done by patching the existing node.
-  if (replacement == node) return;
-
- // Iterate through uses of the original node and replace uses accordingly.
-  UNIMPLEMENTED();
+  DCHECK_EQ(node, replacement);
+  return Changed(replacement);
 }


=======================================
--- /branches/bleeding_edge/src/compiler/js-generic-lowering.h Wed Jul 30 13:54:45 2014 UTC +++ /branches/bleeding_edge/src/compiler/js-generic-lowering.h Thu Aug 14 12:24:37 2014 UTC
@@ -9,8 +9,8 @@

 #include "src/allocation.h"
 #include "src/compiler/graph.h"
+#include "src/compiler/graph-reducer.h"
 #include "src/compiler/js-graph.h"
-#include "src/compiler/lowering-builder.h"
 #include "src/compiler/opcodes.h"
 #include "src/unique.h"

@@ -28,14 +28,13 @@
 class Linkage;

 // Lowers JS-level operators to runtime and IC calls in the "generic" case.
-class JSGenericLowering : public LoweringBuilder {
+class JSGenericLowering : public Reducer {
  public:
   JSGenericLowering(CompilationInfo* info, JSGraph* graph,
-                    MachineOperatorBuilder* machine,
-                    SourcePositionTable* source_positions);
+                    MachineOperatorBuilder* machine);
   virtual ~JSGenericLowering() {}

-  virtual void Lower(Node* node);
+  virtual Reduction Reduce(Node* node);

  protected:
 // Dispatched depending on opcode.
=======================================
--- /branches/bleeding_edge/src/compiler/js-typed-lowering.h Wed Aug 6 08:50:57 2014 UTC +++ /branches/bleeding_edge/src/compiler/js-typed-lowering.h Thu Aug 14 12:24:37 2014 UTC
@@ -7,7 +7,6 @@

 #include "src/compiler/graph-reducer.h"
 #include "src/compiler/js-graph.h"
-#include "src/compiler/lowering-builder.h"
 #include "src/compiler/machine-operator.h"
 #include "src/compiler/node.h"
 #include "src/compiler/simplified-operator.h"
@@ -17,18 +16,15 @@
 namespace compiler {

 // Lowers JS-level operators to simplified operators based on types.
-class JSTypedLowering : public LoweringBuilder {
+class JSTypedLowering : public Reducer {
  public:
-  explicit JSTypedLowering(JSGraph* jsgraph,
-                           SourcePositionTable* source_positions)
-      : LoweringBuilder(jsgraph->graph(), source_positions),
-        jsgraph_(jsgraph),
+  explicit JSTypedLowering(JSGraph* jsgraph)
+      : jsgraph_(jsgraph),
         simplified_(jsgraph->zone()),
         machine_(jsgraph->zone()) {}
   virtual ~JSTypedLowering() {}

-  Reduction Reduce(Node* node);
-  virtual void Lower(Node* node) { Reduce(node); }
+  virtual Reduction Reduce(Node* node);

   JSGraph* jsgraph() { return jsgraph_; }
   Graph* graph() { return jsgraph_->graph(); }
@@ -40,9 +36,7 @@
   MachineOperatorBuilder machine_;

   Reduction ReplaceEagerly(Node* old, Node* node);
-  Reduction NoChange() { return Reducer::NoChange(); }
   Reduction ReplaceWith(Node* node) { return Reducer::Replace(node); }
-  Reduction Changed(Node* node) { return Reducer::Changed(node); }
   Reduction ReduceJSAdd(Node* node);
   Reduction ReduceJSComparison(Node* node);
   Reduction ReduceJSEqual(Node* node, bool invert);
=======================================
--- /branches/bleeding_edge/src/compiler/pipeline.cc Wed Aug 13 14:05:37 2014 UTC +++ /branches/bleeding_edge/src/compiler/pipeline.cc Thu Aug 14 12:24:37 2014 UTC
@@ -211,8 +211,12 @@
       // Lower JSOperators where we can determine types.
       PhaseStats lowering_stats(info(), PhaseStats::CREATE_GRAPH,
                                 "typed lowering");
-      JSTypedLowering lowering(&jsgraph, &source_positions);
-      lowering.LowerAllNodes();
+      SourcePositionTable::Scope pos(&source_positions,
+                                     SourcePosition::Unknown());
+      JSTypedLowering lowering(&jsgraph);
+      GraphReducer graph_reducer(&graph);
+      graph_reducer.AddReducer(&lowering);
+      graph_reducer.ReduceGraph();

       VerifyAndPrintGraph(&graph, "Lowered typed");
     }
@@ -224,9 +228,13 @@
       // Lower any remaining generic JSOperators.
       PhaseStats lowering_stats(info(), PhaseStats::CREATE_GRAPH,
                                 "generic lowering");
+      SourcePositionTable::Scope pos(&source_positions,
+                                     SourcePosition::Unknown());
       MachineOperatorBuilder machine(zone());
- JSGenericLowering lowering(info(), &jsgraph, &machine, &source_positions);
-      lowering.LowerAllNodes();
+      JSGenericLowering lowering(info(), &jsgraph, &machine);
+      GraphReducer graph_reducer(&graph);
+      graph_reducer.AddReducer(&lowering);
+      graph_reducer.ReduceGraph();

       VerifyAndPrintGraph(&graph, "Lowered generic");
     }
=======================================
--- /branches/bleeding_edge/src/compiler/simplified-lowering.cc Thu Aug 14 09:19:54 2014 UTC +++ /branches/bleeding_edge/src/compiler/simplified-lowering.cc Thu Aug 14 12:24:37 2014 UTC
@@ -728,7 +728,9 @@
   RepresentationSelector selector(jsgraph(), zone(), &changer);
   selector.Run(this);

-  LoweringBuilder::LowerAllNodes();
+  GraphReducer graph_reducer(graph());
+  graph_reducer.AddReducer(this);
+  graph_reducer.ReduceGraph();
 }


@@ -963,7 +965,7 @@
 }


-void SimplifiedLowering::Lower(Node* node) {}
+Reduction SimplifiedLowering::Reduce(Node* node) { return NoChange(); }


void SimplifiedLowering::LowerChange(Node* node, Node* effect, Node* control) {
=======================================
--- /branches/bleeding_edge/src/compiler/simplified-lowering.h Mon Aug 11 09:40:02 2014 UTC +++ /branches/bleeding_edge/src/compiler/simplified-lowering.h Thu Aug 14 12:24:37 2014 UTC
@@ -7,7 +7,6 @@

 #include "src/compiler/graph-reducer.h"
 #include "src/compiler/js-graph.h"
-#include "src/compiler/lowering-builder.h"
 #include "src/compiler/machine-operator.h"
 #include "src/compiler/node.h"
 #include "src/compiler/simplified-operator.h"
@@ -16,18 +15,15 @@
 namespace internal {
 namespace compiler {

-class SimplifiedLowering : public LoweringBuilder {
+class SimplifiedLowering : public Reducer {
  public:
-  explicit SimplifiedLowering(JSGraph* jsgraph,
-                              SourcePositionTable* source_positions)
-      : LoweringBuilder(jsgraph->graph(), source_positions),
-        jsgraph_(jsgraph),
-        machine_(jsgraph->zone()) {}
+  explicit SimplifiedLowering(JSGraph* jsgraph)
+      : jsgraph_(jsgraph), machine_(jsgraph->zone()) {}
   virtual ~SimplifiedLowering() {}

   void LowerAllNodes();

-  virtual void Lower(Node* node);
+  virtual Reduction Reduce(Node* node);
   void LowerChange(Node* node, Node* effect, Node* control);

// TODO(titzer): These are exposed for direct testing. Use a friend class.
=======================================
--- /branches/bleeding_edge/test/cctest/compiler/test-changes-lowering.cc Thu Aug 14 09:19:54 2014 UTC +++ /branches/bleeding_edge/test/cctest/compiler/test-changes-lowering.cc Thu Aug 14 12:24:37 2014 UTC
@@ -30,13 +30,11 @@
   explicit ChangesLoweringTester(MachineType p0 = kMachNone)
       : GraphBuilderTester<ReturnType>(p0),
         typer(this->zone()),
-        source_positions(this->graph()),
         jsgraph(this->graph(), this->common(), &typer),
-        lowering(&jsgraph, &source_positions),
+        lowering(&jsgraph),
         function(Handle<JSFunction>::null()) {}

   Typer typer;
-  SourcePositionTable source_positions;
   JSGraph jsgraph;
   SimplifiedLowering lowering;
   Handle<JSFunction> function;
=======================================
--- /branches/bleeding_edge/test/cctest/compiler/test-js-typed-lowering.cc Thu Aug 7 09:14:47 2014 UTC +++ /branches/bleeding_edge/test/cctest/compiler/test-js-typed-lowering.cc Thu Aug 14 12:24:37 2014 UTC
@@ -26,7 +26,6 @@
         common(main_zone()),
         graph(main_zone()),
         typer(main_zone()),
-        source_positions(&graph),
         context_node(NULL) {
     typer.DecorateGraph(&graph);
     Node* s = graph.NewNode(common.Start(num_parameters));
@@ -42,7 +41,6 @@
   CommonOperatorBuilder common;
   Graph graph;
   Typer typer;
-  SourcePositionTable source_positions;
   Node* context_node;

   Node* Parameter(Type* t, int32_t index = 0) {
@@ -53,7 +51,7 @@

   Node* reduce(Node* node) {
     JSGraph jsgraph(&graph, &common, &typer);
-    JSTypedLowering reducer(&jsgraph, &source_positions);
+    JSTypedLowering reducer(&jsgraph);
     Reduction reduction = reducer.Reduce(node);
     if (reduction.Changed()) return reduction.replacement();
     return node;
=======================================
--- /branches/bleeding_edge/test/cctest/compiler/test-simplified-lowering.cc Thu Aug 14 09:52:21 2014 UTC +++ /branches/bleeding_edge/test/cctest/compiler/test-simplified-lowering.cc Thu Aug 14 12:24:37 2014 UTC
@@ -36,12 +36,10 @@
                            MachineType p4 = kMachNone)
       : GraphBuilderTester<ReturnType>(p0, p1, p2, p3, p4),
         typer(this->zone()),
-        source_positions(this->graph()),
         jsgraph(this->graph(), this->common(), &typer),
-        lowering(&jsgraph, &source_positions) {}
+        lowering(&jsgraph) {}

   Typer typer;
-  SourcePositionTable source_positions;
   JSGraph jsgraph;
   SimplifiedLowering lowering;

@@ -645,7 +643,7 @@
   }

   void Lower() {
-    SimplifiedLowering lowering(&jsgraph, NULL);
+    SimplifiedLowering lowering(&jsgraph);
     lowering.LowerAllNodes();
   }

=======================================
--- /branches/bleeding_edge/tools/gyp/v8.gyp    Thu Aug 14 09:19:54 2014 UTC
+++ /branches/bleeding_edge/tools/gyp/v8.gyp    Thu Aug 14 12:24:37 2014 UTC
@@ -390,8 +390,6 @@
         '../../src/compiler/linkage-impl.h',
         '../../src/compiler/linkage.cc',
         '../../src/compiler/linkage.h',
-        '../../src/compiler/lowering-builder.cc',
-        '../../src/compiler/lowering-builder.h',
         '../../src/compiler/machine-node-factory.h',
         '../../src/compiler/machine-operator-reducer.cc',
         '../../src/compiler/machine-operator-reducer.h',

--
--
v8-dev mailing list
v8-dev@googlegroups.com
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 v8-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to