v8/test/unittests/compiler/graph-unittest.cc
bmeurer 722e2e2b36 [turbofan] Remove unused constructor function matching from typer.
This optimization never triggers currently, and is inherently native
context dependent for no real reason (for example it will not properly
detect those constructors in the case of cross native context inlining),
plus it is slow and awkward.  In case we really need this functionality
at some point, we should find a way to make it work with the builtin
function id mechanism that is already in place to match other builtins.

R=jarin@chromium.org,rossberg@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#29365}
2015-06-30 07:36:28 +00:00

148 lines
3.7 KiB
C++

// 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 "test/unittests/compiler/graph-unittest.h"
#include "src/compiler/node-properties.h"
#include "test/unittests/compiler/node-test-utils.h"
namespace v8 {
namespace internal {
namespace compiler {
GraphTest::GraphTest(int num_parameters) : common_(zone()), graph_(zone()) {
graph()->SetStart(graph()->NewNode(common()->Start(num_parameters)));
graph()->SetEnd(graph()->NewNode(common()->End(1), graph()->start()));
}
GraphTest::~GraphTest() {}
Node* GraphTest::Parameter(int32_t index) {
return graph()->NewNode(common()->Parameter(index), graph()->start());
}
Node* GraphTest::Float32Constant(volatile float value) {
return graph()->NewNode(common()->Float32Constant(value));
}
Node* GraphTest::Float64Constant(volatile double value) {
return graph()->NewNode(common()->Float64Constant(value));
}
Node* GraphTest::Int32Constant(int32_t value) {
return graph()->NewNode(common()->Int32Constant(value));
}
Node* GraphTest::Int64Constant(int64_t value) {
return graph()->NewNode(common()->Int64Constant(value));
}
Node* GraphTest::NumberConstant(volatile double value) {
return graph()->NewNode(common()->NumberConstant(value));
}
Node* GraphTest::HeapConstant(const Handle<HeapObject>& value) {
return HeapConstant(Unique<HeapObject>::CreateUninitialized(value));
}
Node* GraphTest::HeapConstant(const Unique<HeapObject>& value) {
Node* node = graph()->NewNode(common()->HeapConstant(value));
Type* type = Type::Constant(value.handle(), zone());
NodeProperties::SetBounds(node, Bounds(type));
return node;
}
Node* GraphTest::FalseConstant() {
return HeapConstant(
Unique<HeapObject>::CreateImmovable(factory()->false_value()));
}
Node* GraphTest::TrueConstant() {
return HeapConstant(
Unique<HeapObject>::CreateImmovable(factory()->true_value()));
}
Node* GraphTest::UndefinedConstant() {
return HeapConstant(
Unique<HeapObject>::CreateImmovable(factory()->undefined_value()));
}
Node* GraphTest::EmptyFrameState() {
Node* state_values = graph()->NewNode(common()->StateValues(0));
return graph()->NewNode(
common()->FrameState(BailoutId::None(), OutputFrameStateCombine::Ignore(),
nullptr),
state_values, state_values, state_values, NumberConstant(0),
UndefinedConstant(), graph()->start());
}
Matcher<Node*> GraphTest::IsFalseConstant() {
return IsHeapConstant(
Unique<HeapObject>::CreateImmovable(factory()->false_value()));
}
Matcher<Node*> GraphTest::IsTrueConstant() {
return IsHeapConstant(
Unique<HeapObject>::CreateImmovable(factory()->true_value()));
}
Matcher<Node*> GraphTest::IsUndefinedConstant() {
return IsHeapConstant(
Unique<HeapObject>::CreateImmovable(factory()->undefined_value()));
}
TypedGraphTest::TypedGraphTest(int num_parameters)
: GraphTest(num_parameters), typer_(isolate(), graph()) {}
TypedGraphTest::~TypedGraphTest() {}
Node* TypedGraphTest::Parameter(Type* type, int32_t index) {
Node* node = GraphTest::Parameter(index);
NodeProperties::SetBounds(node, Bounds(type));
return node;
}
namespace {
const Operator kDummyOperator(0, Operator::kNoProperties, "Dummy", 0, 0, 0, 1,
0, 0);
} // namespace
TEST_F(GraphTest, NewNode) {
Node* n0 = graph()->NewNode(&kDummyOperator);
Node* n1 = graph()->NewNode(&kDummyOperator);
EXPECT_NE(n0, n1);
EXPECT_LT(0u, n0->id());
EXPECT_LT(0u, n1->id());
EXPECT_NE(n0->id(), n1->id());
EXPECT_EQ(&kDummyOperator, n0->op());
EXPECT_EQ(&kDummyOperator, n1->op());
}
} // namespace compiler
} // namespace internal
} // namespace v8