[turbofan] Minor cleanup to reduce code duplication.
authorbmeurer <bmeurer@chromium.org>
Mon, 22 Dec 2014 14:37:16 +0000 (06:37 -0800)
committerCommit bot <commit-bot@chromium.org>
Mon, 22 Dec 2014 14:37:22 +0000 (14:37 +0000)
TEST=unittests
R=jochen@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#25927}

test/unittests/compiler/change-lowering-unittest.cc
test/unittests/compiler/graph-unittest.cc
test/unittests/compiler/graph-unittest.h
test/unittests/compiler/js-builtin-reducer-unittest.cc
test/unittests/compiler/js-typed-lowering-unittest.cc
test/unittests/compiler/simplified-operator-reducer-unittest.cc

index e7abe23..199fb30 100644 (file)
@@ -61,10 +61,6 @@ class ChangeLoweringTest : public GraphTest {
                   : SmiTagging<8>::SmiValueSize();
   }
 
-  Node* Parameter(int32_t index = 0) {
-    return graph()->NewNode(common()->Parameter(index), graph()->start());
-  }
-
   Reduction Reduce(Node* node) {
     MachineOperatorBuilder machine(zone(), WordRepresentation());
     JSOperatorBuilder javascript(zone());
index 2cfd23a..9543258 100644 (file)
@@ -4,8 +4,6 @@
 
 #include "test/unittests/compiler/graph-unittest.h"
 
-#include <ostream>  // NOLINT(readability/streams)
-
 #include "src/compiler/node-properties-inl.h"
 #include "test/unittests/compiler/node-test-utils.h"
 
@@ -93,6 +91,20 @@ Matcher<Node*> GraphTest::IsTrueConstant() {
       Unique<HeapObject>::CreateImmovable(factory()->true_value()));
 }
 
+
+TypedGraphTest::TypedGraphTest(int num_parameters)
+    : GraphTest(num_parameters), typer_(graph(), MaybeHandle<Context>()) {}
+
+
+TypedGraphTest::~TypedGraphTest() {}
+
+
+Node* TypedGraphTest::Parameter(Type* type, int32_t index) {
+  Node* node = GraphTest::Parameter(index);
+  NodeProperties::SetBounds(node, Bounds(type));
+  return node;
+}
+
 }  // namespace compiler
 }  // namespace internal
 }  // namespace v8
index 32341e9..7c75161 100644 (file)
@@ -7,7 +7,6 @@
 
 #include "src/compiler/common-operator.h"
 #include "src/compiler/graph.h"
-#include "src/compiler/machine-operator.h"
 #include "src/compiler/typer.h"
 #include "test/unittests/test-utils.h"
 #include "testing/gmock/include/gmock/gmock.h"
@@ -29,11 +28,11 @@ using ::testing::Matcher;
 
 class GraphTest : public TestWithContext, public TestWithZone {
  public:
-  explicit GraphTest(int parameters = 1);
+  explicit GraphTest(int num_parameters = 1);
   ~GraphTest() OVERRIDE;
 
  protected:
-  Node* Parameter(int32_t index);
+  Node* Parameter(int32_t index = 0);
   Node* Float32Constant(volatile float value);
   Node* Float64Constant(volatile double value);
   Node* Int32Constant(int32_t value);
@@ -62,10 +61,13 @@ class GraphTest : public TestWithContext, public TestWithZone {
 
 class TypedGraphTest : public GraphTest {
  public:
-  explicit TypedGraphTest(int parameters = 1)
-      : GraphTest(parameters), typer_(graph(), MaybeHandle<Context>()) {}
+  explicit TypedGraphTest(int num_parameters = 1);
+  ~TypedGraphTest() OVERRIDE;
 
  protected:
+  Node* Parameter(int32_t index = 0) { return GraphTest::Parameter(index); }
+  Node* Parameter(Type* type, int32_t index = 0);
+
   Typer* typer() { return &typer_; }
 
  private:
index 0747f0c..87d1ad5 100644 (file)
@@ -29,12 +29,6 @@ class JSBuiltinReducerTest : public TypedGraphTest {
     return reducer.Reduce(node);
   }
 
-  Node* Parameter(Type* t, int32_t index = 0) {
-    Node* n = graph()->NewNode(common()->Parameter(index), graph()->start());
-    NodeProperties::SetBounds(n, Bounds(Type::None(), t));
-    return n;
-  }
-
   Handle<JSFunction> MathFunction(const char* name) {
     Handle<Object> m =
         JSObject::GetProperty(isolate()->global_object(),
index 883683d..e4ea4a5 100644 (file)
@@ -50,12 +50,6 @@ class JSTypedLoweringTest : public TypedGraphTest {
     return reducer.Reduce(node);
   }
 
-  Node* Parameter(Type* type, int index = 0) {
-    Node* node = graph()->NewNode(common()->Parameter(index), graph()->start());
-    NodeProperties::SetBounds(node, Bounds(Type::None(), type));
-    return node;
-  }
-
   Handle<JSArrayBuffer> NewArrayBuffer(void* bytes, size_t byte_length) {
     Handle<JSArrayBuffer> buffer = factory()->NewJSArrayBuffer();
     Runtime::SetupArrayBuffer(isolate(), buffer, true, bytes, byte_length);
index 8a42f7d..066cbe9 100644 (file)
@@ -18,7 +18,7 @@ class SimplifiedOperatorReducerTest : public GraphTest {
  public:
   explicit SimplifiedOperatorReducerTest(int num_parameters = 1)
       : GraphTest(num_parameters), simplified_(zone()) {}
-  virtual ~SimplifiedOperatorReducerTest() {}
+  ~SimplifiedOperatorReducerTest() OVERRIDE {}
 
  protected:
   Reduction Reduce(Node* node) {
@@ -43,7 +43,7 @@ class SimplifiedOperatorReducerTestWithParam
  public:
   explicit SimplifiedOperatorReducerTestWithParam(int num_parameters = 1)
       : SimplifiedOperatorReducerTest(num_parameters) {}
-  virtual ~SimplifiedOperatorReducerTestWithParam() {}
+  ~SimplifiedOperatorReducerTestWithParam() OVERRIDE {}
 };