2014-08-18 06:54:07 +00:00
|
|
|
// 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.
|
|
|
|
|
2014-09-01 10:26:12 +00:00
|
|
|
#include "src/compiler/common-operator.h"
|
2014-08-18 06:54:07 +00:00
|
|
|
#include "src/compiler/operator-properties-inl.h"
|
2014-09-04 08:44:03 +00:00
|
|
|
#include "src/test/test-utils.h"
|
2014-08-18 06:54:07 +00:00
|
|
|
|
|
|
|
namespace v8 {
|
|
|
|
namespace internal {
|
|
|
|
namespace compiler {
|
|
|
|
|
2014-09-01 10:26:12 +00:00
|
|
|
namespace {
|
|
|
|
|
2014-09-04 08:44:03 +00:00
|
|
|
class CommonOperatorTest : public TestWithZone {
|
2014-09-01 10:26:12 +00:00
|
|
|
public:
|
|
|
|
CommonOperatorTest() : common_(zone()) {}
|
|
|
|
virtual ~CommonOperatorTest() {}
|
|
|
|
|
|
|
|
CommonOperatorBuilder* common() { return &common_; }
|
2014-08-19 04:54:06 +00:00
|
|
|
|
2014-09-01 10:26:12 +00:00
|
|
|
private:
|
|
|
|
CommonOperatorBuilder common_;
|
|
|
|
};
|
2014-08-19 04:54:06 +00:00
|
|
|
|
2014-08-18 06:54:07 +00:00
|
|
|
|
2014-09-01 10:26:12 +00:00
|
|
|
const int kArguments[] = {1, 5, 6, 42, 100, 10000, kMaxInt};
|
2014-08-18 06:54:07 +00:00
|
|
|
|
2014-09-01 10:26:12 +00:00
|
|
|
} // namespace
|
2014-08-18 06:54:07 +00:00
|
|
|
|
2014-08-18 11:36:06 +00:00
|
|
|
|
|
|
|
TEST_F(CommonOperatorTest, ControlEffect) {
|
|
|
|
Operator* op = common()->ControlEffect();
|
|
|
|
EXPECT_EQ(1, OperatorProperties::GetControlInputCount(op));
|
|
|
|
EXPECT_EQ(1, OperatorProperties::GetTotalInputCount(op));
|
|
|
|
EXPECT_EQ(0, OperatorProperties::GetControlOutputCount(op));
|
|
|
|
EXPECT_EQ(1, OperatorProperties::GetEffectOutputCount(op));
|
|
|
|
EXPECT_EQ(0, OperatorProperties::GetValueOutputCount(op));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-08-19 04:54:06 +00:00
|
|
|
TEST_F(CommonOperatorTest, ValueEffect) {
|
|
|
|
TRACED_FOREACH(int, arguments, kArguments) {
|
|
|
|
Operator* op = common()->ValueEffect(arguments);
|
|
|
|
EXPECT_EQ(arguments, OperatorProperties::GetValueInputCount(op));
|
|
|
|
EXPECT_EQ(arguments, OperatorProperties::GetTotalInputCount(op));
|
|
|
|
EXPECT_EQ(0, OperatorProperties::GetControlOutputCount(op));
|
|
|
|
EXPECT_EQ(1, OperatorProperties::GetEffectOutputCount(op));
|
|
|
|
EXPECT_EQ(0, OperatorProperties::GetValueOutputCount(op));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-08-18 11:36:06 +00:00
|
|
|
TEST_F(CommonOperatorTest, Finish) {
|
|
|
|
TRACED_FOREACH(int, arguments, kArguments) {
|
|
|
|
Operator* op = common()->Finish(arguments);
|
|
|
|
EXPECT_EQ(1, OperatorProperties::GetValueInputCount(op));
|
|
|
|
EXPECT_EQ(arguments, OperatorProperties::GetEffectInputCount(op));
|
|
|
|
EXPECT_EQ(arguments + 1, OperatorProperties::GetTotalInputCount(op));
|
|
|
|
EXPECT_EQ(0, OperatorProperties::GetControlOutputCount(op));
|
|
|
|
EXPECT_EQ(0, OperatorProperties::GetEffectOutputCount(op));
|
|
|
|
EXPECT_EQ(1, OperatorProperties::GetValueOutputCount(op));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-18 06:54:07 +00:00
|
|
|
} // namespace compiler
|
|
|
|
} // namespace internal
|
|
|
|
} // namespace v8
|