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

Unified Diff: test/cctest/compiler/test-simplified-lowering.cc

Issue 439223004: Add support for untagged LoadField, StoreField, LoadElement, and StoreElement simplfied operators. … (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address review comments. Created 6 years, 4 months 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 | « src/compiler/simplified-operator.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/compiler/test-simplified-lowering.cc
diff --git a/test/cctest/compiler/test-simplified-lowering.cc b/test/cctest/compiler/test-simplified-lowering.cc
index 43a6594e609747eacd0787c94f2b8817445a63d3..97b42adf42a22aaef2eaeaf15adbc6382765e882 100644
--- a/test/cctest/compiler/test-simplified-lowering.cc
+++ b/test/cctest/compiler/test-simplified-lowering.cc
@@ -86,22 +86,23 @@ class SimplifiedGraphBuilderTester : public GraphBuilderTester<ReturnType> {
namespace {
FieldAccess ForJSObjectMap() {
- FieldAccess access = {JSObject::kMapOffset, Handle<Name>(), Type::Any(),
- kMachineTagged};
+ FieldAccess access = {kTaggedBase, JSObject::kMapOffset, Handle<Name>(),
+ Type::Any(), kMachineTagged};
return access;
}
FieldAccess ForJSObjectProperties() {
- FieldAccess access = {JSObject::kPropertiesOffset, Handle<Name>(),
- Type::Any(), kMachineTagged};
+ FieldAccess access = {kTaggedBase, JSObject::kPropertiesOffset,
+ Handle<Name>(), Type::Any(), kMachineTagged};
return access;
}
FieldAccess ForArrayBufferBackingStore() {
FieldAccess access = {
- JSArrayBuffer::kBackingStoreOffset, Handle<Name>(), Type::UntaggedPtr(),
+ kTaggedBase, JSArrayBuffer::kBackingStoreOffset,
+ Handle<Name>(), Type::UntaggedPtr(),
MachineOperatorBuilder::pointer_rep(),
};
return access;
@@ -109,13 +110,16 @@ FieldAccess ForArrayBufferBackingStore() {
ElementAccess ForFixedArrayElement() {
- ElementAccess access = {FixedArray::kHeaderSize, Type::Any(), kMachineTagged};
+ ElementAccess access = {kTaggedBase, FixedArray::kHeaderSize, Type::Any(),
+ kMachineTagged};
return access;
}
ElementAccess ForBackingStoreElement(MachineRepresentation rep) {
- ElementAccess access = {kNonHeapObjectHeaderSize, Type::Any(), rep};
+ ElementAccess access = {kUntaggedBase,
+ kNonHeapObjectHeaderSize - kHeapObjectTag,
+ Type::Any(), rep};
return access;
}
}
@@ -311,3 +315,102 @@ TEST(RunCopyFixedArray) {
CHECK_EQ(src_copy->get(i), dst->get(i));
}
}
+
+
+TEST(RunLoadFieldFromUntaggedBase) {
+ Smi* smis[] = {Smi::FromInt(1), Smi::FromInt(2), Smi::FromInt(3)};
+
+ for (size_t i = 0; i < ARRAY_SIZE(smis); i++) {
+ FieldAccess access = {kUntaggedBase, // untagged base
+ i * sizeof(Smi*), // offset
+ Handle<Name>(), Type::Integral32(), kMachineTagged};
+
+ SimplifiedGraphBuilderTester<Object*> t;
+ Node* load = t.LoadField(access, t.PointerConstant(smis));
+ t.Return(load);
+ t.LowerAllNodes();
+
+ for (int j = -5; j <= 5; j++) {
+ Smi* expected = Smi::FromInt(j);
+ smis[i] = expected;
+ CHECK_EQ(expected, t.Call());
+ }
+ }
+}
+
+
+TEST(RunStoreFieldToUntaggedBase) {
+ Smi* smis[] = {Smi::FromInt(1), Smi::FromInt(2), Smi::FromInt(3)};
+
+ for (size_t i = 0; i < ARRAY_SIZE(smis); i++) {
+ FieldAccess access = {kUntaggedBase, // untagged base
+ i * sizeof(Smi*), // offset
+ Handle<Name>(), Type::Integral32(), kMachineTagged};
+
+ SimplifiedGraphBuilderTester<Object*> t(kMachineTagged);
+ Node* p0 = t.Parameter(0);
+ t.StoreField(access, t.PointerConstant(smis), p0);
+ t.Return(p0);
+ t.LowerAllNodes();
+
+ for (int j = -5; j <= 5; j++) {
+ Smi* expected = Smi::FromInt(j);
+ smis[i] = Smi::FromInt(-100);
+ CHECK_EQ(expected, t.Call(expected));
+ CHECK_EQ(expected, smis[i]);
+ }
+ }
+}
+
+
+TEST(RunLoadElementFromUntaggedBase) {
+ Smi* smis[] = {Smi::FromInt(1), Smi::FromInt(2), Smi::FromInt(3),
+ Smi::FromInt(4), Smi::FromInt(5)};
+
+ for (size_t i = 0; i < ARRAY_SIZE(smis); i++) { // for header sizes
+ for (size_t j = i; j < ARRAY_SIZE(smis); j++) { // for element index
+ ElementAccess access = {kUntaggedBase, // untagged base
+ i * sizeof(Smi*), // header size
+ Type::Integral32(), kMachineTagged};
+
+ SimplifiedGraphBuilderTester<Object*> t;
+ Node* load =
+ t.LoadElement(access, t.PointerConstant(smis), t.Int32Constant(j));
+ t.Return(load);
+ t.LowerAllNodes();
+
+ for (int k = -5; k <= 5; k++) {
+ Smi* expected = Smi::FromInt(k);
+ smis[i + j] = expected;
+ CHECK_EQ(expected, t.Call());
+ }
+ }
+ }
+}
+
+
+TEST(RunStoreElementFromUntaggedBase) {
+ Smi* smis[] = {Smi::FromInt(1), Smi::FromInt(2), Smi::FromInt(3),
+ Smi::FromInt(4), Smi::FromInt(5)};
+
+ for (size_t i = 0; i < ARRAY_SIZE(smis); i++) { // for header sizes
+ for (size_t j = i; j < ARRAY_SIZE(smis); j++) { // for element index
+ ElementAccess access = {kUntaggedBase, // untagged base
+ i * sizeof(Smi*), // header size
+ Type::Integral32(), kMachineTagged};
+
+ SimplifiedGraphBuilderTester<Object*> t(kMachineTagged);
+ Node* p0 = t.Parameter(0);
+ t.StoreElement(access, t.PointerConstant(smis), t.Int32Constant(j), p0);
+ t.Return(p0);
+ t.LowerAllNodes();
+
+ for (int k = -5; k <= 5; k++) {
+ Smi* expected = Smi::FromInt(k);
+ smis[i + j] = Smi::FromInt(-100);
+ CHECK_EQ(expected, t.Call(expected));
+ CHECK_EQ(expected, smis[i + j]);
+ }
+ }
+ }
+}
« no previous file with comments | « src/compiler/simplified-operator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698