Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(62)

Unified Diff: test/unittests/compiler/simplified-operator-unittest.cc

Issue 763963002: [turbofan] Add checked load/store operators. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Reapply fix. Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/unittests/compiler/simplified-operator-reducer-unittest.cc ('k') | test/unittests/test-utils.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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());
« no previous file with comments | « test/unittests/compiler/simplified-operator-reducer-unittest.cc ('k') | test/unittests/test-utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698