Index: test/unittests/compiler/simplified-operator-unittest.cc |
diff --git a/test/unittests/compiler/simplified-operator-unittest.cc b/test/unittests/compiler/simplified-operator-unittest.cc |
index 031a8974f86b68f8501822b4df1bf968fe6400d9..b4567d6af73eae55407648f57898a878337b20eb 100644 |
--- a/test/unittests/compiler/simplified-operator-unittest.cc |
+++ b/test/unittests/compiler/simplified-operator-unittest.cc |
@@ -114,49 +114,116 @@ INSTANTIATE_TEST_CASE_P(SimplifiedOperatorTest, SimplifiedPureOperatorTest, |
// ----------------------------------------------------------------------------- |
+// Buffer access operators. |
+ |
+ |
+namespace { |
+ |
+const ExternalArrayType kExternalArrayTypes[] = { |
+ kExternalUint8Array, kExternalInt8Array, kExternalUint16Array, |
+ kExternalInt16Array, kExternalUint32Array, kExternalInt32Array, |
+ kExternalFloat32Array, kExternalFloat64Array}; |
+ |
+} // namespace |
+ |
+ |
+class SimplifiedBufferAccessOperatorTest |
+ : public TestWithZone, |
+ public ::testing::WithParamInterface<ExternalArrayType> {}; |
+ |
+ |
+TEST_P(SimplifiedBufferAccessOperatorTest, InstancesAreGloballyShared) { |
+ BufferAccess const access(GetParam()); |
+ SimplifiedOperatorBuilder simplified1(zone()); |
+ SimplifiedOperatorBuilder simplified2(zone()); |
+ EXPECT_EQ(simplified1.LoadBuffer(access), simplified2.LoadBuffer(access)); |
+ EXPECT_EQ(simplified1.StoreBuffer(access), simplified2.StoreBuffer(access)); |
+} |
+ |
+ |
+TEST_P(SimplifiedBufferAccessOperatorTest, LoadBuffer) { |
+ SimplifiedOperatorBuilder simplified(zone()); |
+ BufferAccess const access(GetParam()); |
+ const Operator* op = simplified.LoadBuffer(access); |
+ |
+ EXPECT_EQ(IrOpcode::kLoadBuffer, op->opcode()); |
+ EXPECT_EQ(Operator::kNoThrow | Operator::kNoWrite, op->properties()); |
+ EXPECT_EQ(access, BufferAccessOf(op)); |
+ |
+ EXPECT_EQ(3, op->ValueInputCount()); |
+ EXPECT_EQ(1, op->EffectInputCount()); |
+ EXPECT_EQ(1, op->ControlInputCount()); |
+ EXPECT_EQ(5, OperatorProperties::GetTotalInputCount(op)); |
+ |
+ EXPECT_EQ(1, op->ValueOutputCount()); |
+ EXPECT_EQ(1, op->EffectOutputCount()); |
+ EXPECT_EQ(0, op->ControlOutputCount()); |
+} |
+ |
+ |
+TEST_P(SimplifiedBufferAccessOperatorTest, StoreBuffer) { |
+ SimplifiedOperatorBuilder simplified(zone()); |
+ BufferAccess const access(GetParam()); |
+ const Operator* op = simplified.StoreBuffer(access); |
+ |
+ EXPECT_EQ(IrOpcode::kStoreBuffer, op->opcode()); |
+ EXPECT_EQ(Operator::kNoRead | Operator::kNoThrow, op->properties()); |
+ EXPECT_EQ(access, BufferAccessOf(op)); |
+ |
+ EXPECT_EQ(4, op->ValueInputCount()); |
+ EXPECT_EQ(1, op->EffectInputCount()); |
+ EXPECT_EQ(1, op->ControlInputCount()); |
+ EXPECT_EQ(6, OperatorProperties::GetTotalInputCount(op)); |
+ |
+ EXPECT_EQ(0, op->ValueOutputCount()); |
+ EXPECT_EQ(1, op->EffectOutputCount()); |
+ EXPECT_EQ(0, op->ControlOutputCount()); |
+} |
+ |
+ |
+INSTANTIATE_TEST_CASE_P(SimplifiedOperatorTest, |
+ SimplifiedBufferAccessOperatorTest, |
+ ::testing::ValuesIn(kExternalArrayTypes)); |
+ |
+ |
+// ----------------------------------------------------------------------------- |
// Element access operators. |
+ |
namespace { |
const ElementAccess kElementAccesses[] = { |
- {kNoBoundsCheck, kTaggedBase, FixedArray::kHeaderSize, Type::Any(), |
- kMachAnyTagged}, |
- {kNoBoundsCheck, kUntaggedBase, kNonHeapObjectHeaderSize - kHeapObjectTag, |
- Type::Any(), kMachInt8}, |
- {kNoBoundsCheck, kUntaggedBase, kNonHeapObjectHeaderSize - kHeapObjectTag, |
- Type::Any(), kMachInt16}, |
- {kNoBoundsCheck, kUntaggedBase, kNonHeapObjectHeaderSize - kHeapObjectTag, |
- Type::Any(), kMachInt32}, |
- {kNoBoundsCheck, kUntaggedBase, kNonHeapObjectHeaderSize - kHeapObjectTag, |
- Type::Any(), kMachUint8}, |
- {kNoBoundsCheck, kUntaggedBase, kNonHeapObjectHeaderSize - kHeapObjectTag, |
- Type::Any(), kMachUint16}, |
- {kNoBoundsCheck, kUntaggedBase, kNonHeapObjectHeaderSize - kHeapObjectTag, |
- Type::Any(), kMachUint32}, |
- {kTypedArrayBoundsCheck, kUntaggedBase, 0, Type::Signed32(), kMachInt8}, |
- {kTypedArrayBoundsCheck, kUntaggedBase, 0, Type::Unsigned32(), kMachUint8}, |
- {kTypedArrayBoundsCheck, kUntaggedBase, 0, Type::Signed32(), kMachInt16}, |
- {kTypedArrayBoundsCheck, kUntaggedBase, 0, Type::Unsigned32(), kMachUint16}, |
- {kTypedArrayBoundsCheck, kUntaggedBase, 0, Type::Signed32(), kMachInt32}, |
- {kTypedArrayBoundsCheck, kUntaggedBase, 0, Type::Unsigned32(), kMachUint32}, |
- {kTypedArrayBoundsCheck, kUntaggedBase, 0, Type::Number(), kRepFloat32}, |
- {kTypedArrayBoundsCheck, kUntaggedBase, 0, Type::Number(), kRepFloat64}, |
- {kTypedArrayBoundsCheck, kTaggedBase, FixedTypedArrayBase::kDataOffset, |
- Type::Signed32(), kMachInt8}, |
- {kTypedArrayBoundsCheck, kTaggedBase, FixedTypedArrayBase::kDataOffset, |
- Type::Unsigned32(), kMachUint8}, |
- {kTypedArrayBoundsCheck, kTaggedBase, FixedTypedArrayBase::kDataOffset, |
- Type::Signed32(), kMachInt16}, |
- {kTypedArrayBoundsCheck, kTaggedBase, FixedTypedArrayBase::kDataOffset, |
- Type::Unsigned32(), kMachUint16}, |
- {kTypedArrayBoundsCheck, kTaggedBase, FixedTypedArrayBase::kDataOffset, |
- Type::Signed32(), kMachInt32}, |
- {kTypedArrayBoundsCheck, kTaggedBase, FixedTypedArrayBase::kDataOffset, |
- Type::Unsigned32(), kMachUint32}, |
- {kTypedArrayBoundsCheck, kTaggedBase, FixedTypedArrayBase::kDataOffset, |
- Type::Number(), kRepFloat32}, |
- {kTypedArrayBoundsCheck, kTaggedBase, FixedTypedArrayBase::kDataOffset, |
- Type::Number(), kRepFloat64}}; |
+ {kTaggedBase, FixedArray::kHeaderSize, Type::Any(), kMachAnyTagged}, |
+ {kUntaggedBase, 0, Type::Any(), kMachInt8}, |
+ {kUntaggedBase, 0, Type::Any(), kMachInt16}, |
+ {kUntaggedBase, 0, Type::Any(), kMachInt32}, |
+ {kUntaggedBase, 0, Type::Any(), kMachUint8}, |
+ {kUntaggedBase, 0, Type::Any(), kMachUint16}, |
+ {kUntaggedBase, 0, Type::Any(), kMachUint32}, |
+ {kUntaggedBase, 0, Type::Signed32(), kMachInt8}, |
+ {kUntaggedBase, 0, Type::Unsigned32(), kMachUint8}, |
+ {kUntaggedBase, 0, Type::Signed32(), kMachInt16}, |
+ {kUntaggedBase, 0, Type::Unsigned32(), kMachUint16}, |
+ {kUntaggedBase, 0, Type::Signed32(), kMachInt32}, |
+ {kUntaggedBase, 0, Type::Unsigned32(), kMachUint32}, |
+ {kUntaggedBase, 0, Type::Number(), kRepFloat32}, |
+ {kUntaggedBase, 0, Type::Number(), kRepFloat64}, |
+ {kTaggedBase, FixedTypedArrayBase::kDataOffset, Type::Signed32(), |
+ kMachInt8}, |
+ {kTaggedBase, FixedTypedArrayBase::kDataOffset, Type::Unsigned32(), |
+ kMachUint8}, |
+ {kTaggedBase, FixedTypedArrayBase::kDataOffset, Type::Signed32(), |
+ kMachInt16}, |
+ {kTaggedBase, FixedTypedArrayBase::kDataOffset, Type::Unsigned32(), |
+ kMachUint16}, |
+ {kTaggedBase, FixedTypedArrayBase::kDataOffset, Type::Signed32(), |
+ kMachInt32}, |
+ {kTaggedBase, FixedTypedArrayBase::kDataOffset, Type::Unsigned32(), |
+ kMachUint32}, |
+ {kTaggedBase, FixedTypedArrayBase::kDataOffset, Type::Number(), |
+ kRepFloat32}, |
+ {kTaggedBase, FixedTypedArrayBase::kDataOffset, Type::Number(), |
+ kRepFloat64}}; |
} // namespace |
@@ -175,9 +242,9 @@ TEST_P(SimplifiedElementAccessOperatorTest, LoadElement) { |
EXPECT_EQ(Operator::kNoThrow | Operator::kNoWrite, op->properties()); |
EXPECT_EQ(access, ElementAccessOf(op)); |
- EXPECT_EQ(3, op->ValueInputCount()); |
+ EXPECT_EQ(2, op->ValueInputCount()); |
EXPECT_EQ(1, op->EffectInputCount()); |
- EXPECT_EQ(0, op->ControlInputCount()); |
+ EXPECT_EQ(1, op->ControlInputCount()); |
EXPECT_EQ(4, OperatorProperties::GetTotalInputCount(op)); |
EXPECT_EQ(1, op->ValueOutputCount()); |
@@ -195,10 +262,10 @@ TEST_P(SimplifiedElementAccessOperatorTest, StoreElement) { |
EXPECT_EQ(Operator::kNoRead | Operator::kNoThrow, op->properties()); |
EXPECT_EQ(access, ElementAccessOf(op)); |
- EXPECT_EQ(4, op->ValueInputCount()); |
+ EXPECT_EQ(3, op->ValueInputCount()); |
EXPECT_EQ(1, op->EffectInputCount()); |
EXPECT_EQ(1, op->ControlInputCount()); |
- EXPECT_EQ(6, OperatorProperties::GetTotalInputCount(op)); |
+ EXPECT_EQ(5, OperatorProperties::GetTotalInputCount(op)); |
EXPECT_EQ(0, op->ValueOutputCount()); |
EXPECT_EQ(1, op->EffectOutputCount()); |