[turbofan] Minor cleanup to reduce code duplication.
TEST=unittests R=jochen@chromium.org Review URL: https://codereview.chromium.org/819103002 Cr-Commit-Position: refs/heads/master@{#25927}
This commit is contained in:
parent
18b1e6d353
commit
00013a5692
@ -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());
|
||||
|
@ -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
|
||||
|
@ -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:
|
||||
|
@ -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(),
|
||||
|
@ -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);
|
||||
|
@ -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 {}
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user