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

Unified Diff: test/cctest/test-transitions.cc

Issue 988703002: Revert of Revert of Simplify and compact transitions storage (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix extra ';', again Created 5 years, 9 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 | « test/cctest/test-migrations.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-transitions.cc
diff --git a/test/cctest/test-transitions.cc b/test/cctest/test-transitions.cc
index 59c9f74c96dbdb41ef34ccb1b55e634936fcf522..800c2a0e4436950798df310c1f2d7fa4eaf6e1f7 100644
--- a/test/cctest/test-transitions.cc
+++ b/test/cctest/test-transitions.cc
@@ -20,16 +20,6 @@ using namespace v8::internal;
// Helper functions.
//
-static void ConnectTransition(Handle<Map> parent,
- Handle<TransitionArray> transitions,
- Handle<Map> child) {
- if (!parent->HasTransitionArray() || *transitions != parent->transitions()) {
- parent->set_transitions(*transitions);
- }
- child->SetBackPointer(*parent);
-}
-
-
static void CheckPropertyDetailsFieldsConsistency(PropertyType type,
PropertyKind kind,
PropertyLocation location) {
@@ -69,34 +59,32 @@ TEST(TransitionArray_SimpleFieldTransitions) {
attributes, Representation::Tagged(),
OMIT_TRANSITION).ToHandleChecked();
- CHECK(!map0->HasTransitionArray());
- Handle<TransitionArray> transitions = TransitionArray::Allocate(isolate, 0);
- CHECK(transitions->IsFullTransitionArray());
-
- int transition;
- transitions =
- transitions->Insert(map0, name1, map1, SIMPLE_PROPERTY_TRANSITION);
- ConnectTransition(map0, transitions, map1);
- CHECK(transitions->IsSimpleTransition());
- transition = transitions->Search(kData, *name1, attributes);
- CHECK_EQ(TransitionArray::kSimpleTransitionIndex, transition);
- CHECK_EQ(*name1, transitions->GetKey(transition));
- CHECK_EQ(*map1, transitions->GetTarget(transition));
-
- transitions =
- transitions->Insert(map0, name2, map2, SIMPLE_PROPERTY_TRANSITION);
- ConnectTransition(map0, transitions, map2);
- CHECK(transitions->IsFullTransitionArray());
-
- transition = transitions->Search(kData, *name1, attributes);
- CHECK_EQ(*name1, transitions->GetKey(transition));
- CHECK_EQ(*map1, transitions->GetTarget(transition));
-
- transition = transitions->Search(kData, *name2, attributes);
- CHECK_EQ(*name2, transitions->GetKey(transition));
- CHECK_EQ(*map2, transitions->GetTarget(transition));
-
- DCHECK(transitions->IsSortedNoDuplicates());
+ CHECK(map0->raw_transitions()->IsSmi());
+
+ TransitionArray::Insert(map0, name1, map1, SIMPLE_PROPERTY_TRANSITION);
+ CHECK(TransitionArray::IsSimpleTransition(map0->raw_transitions()));
+ CHECK_EQ(*map1,
+ TransitionArray::SearchTransition(*map0, kData, *name1, attributes));
+ CHECK_EQ(1, TransitionArray::NumberOfTransitions(map0->raw_transitions()));
+ CHECK_EQ(*name1, TransitionArray::GetKey(map0->raw_transitions(), 0));
+ CHECK_EQ(*map1, TransitionArray::GetTarget(map0->raw_transitions(), 0));
+
+ TransitionArray::Insert(map0, name2, map2, SIMPLE_PROPERTY_TRANSITION);
+ CHECK(TransitionArray::IsFullTransitionArray(map0->raw_transitions()));
+
+ CHECK_EQ(*map1,
+ TransitionArray::SearchTransition(*map0, kData, *name1, attributes));
+ CHECK_EQ(*map2,
+ TransitionArray::SearchTransition(*map0, kData, *name2, attributes));
+ CHECK_EQ(2, TransitionArray::NumberOfTransitions(map0->raw_transitions()));
+ for (int i = 0; i < 2; i++) {
+ Name* key = TransitionArray::GetKey(map0->raw_transitions(), i);
+ Map* target = TransitionArray::GetTarget(map0->raw_transitions(), i);
+ CHECK((key == *name1 && target == *map1) ||
+ (key == *name2 && target == *map2));
+ }
+
+ DCHECK(TransitionArray::IsSortedNoDuplicates(*map0));
}
@@ -120,31 +108,32 @@ TEST(TransitionArray_FullFieldTransitions) {
attributes, Representation::Tagged(),
OMIT_TRANSITION).ToHandleChecked();
- CHECK(!map0->HasTransitionArray());
- Handle<TransitionArray> transitions = TransitionArray::Allocate(isolate, 0);
- CHECK(transitions->IsFullTransitionArray());
-
- int transition;
- transitions = transitions->Insert(map0, name1, map1, PROPERTY_TRANSITION);
- ConnectTransition(map0, transitions, map1);
- CHECK(transitions->IsFullTransitionArray());
- transition = transitions->Search(kData, *name1, attributes);
- CHECK_EQ(*name1, transitions->GetKey(transition));
- CHECK_EQ(*map1, transitions->GetTarget(transition));
-
- transitions = transitions->Insert(map0, name2, map2, PROPERTY_TRANSITION);
- ConnectTransition(map0, transitions, map2);
- CHECK(transitions->IsFullTransitionArray());
-
- transition = transitions->Search(kData, *name1, attributes);
- CHECK_EQ(*name1, transitions->GetKey(transition));
- CHECK_EQ(*map1, transitions->GetTarget(transition));
-
- transition = transitions->Search(kData, *name2, attributes);
- CHECK_EQ(*name2, transitions->GetKey(transition));
- CHECK_EQ(*map2, transitions->GetTarget(transition));
+ CHECK(map0->raw_transitions()->IsSmi());
+
+ TransitionArray::Insert(map0, name1, map1, PROPERTY_TRANSITION);
+ CHECK(TransitionArray::IsFullTransitionArray(map0->raw_transitions()));
+ CHECK_EQ(*map1,
+ TransitionArray::SearchTransition(*map0, kData, *name1, attributes));
+ CHECK_EQ(1, TransitionArray::NumberOfTransitions(map0->raw_transitions()));
+ CHECK_EQ(*name1, TransitionArray::GetKey(map0->raw_transitions(), 0));
+ CHECK_EQ(*map1, TransitionArray::GetTarget(map0->raw_transitions(), 0));
+
+ TransitionArray::Insert(map0, name2, map2, PROPERTY_TRANSITION);
+ CHECK(TransitionArray::IsFullTransitionArray(map0->raw_transitions()));
+
+ CHECK_EQ(*map1,
+ TransitionArray::SearchTransition(*map0, kData, *name1, attributes));
+ CHECK_EQ(*map2,
+ TransitionArray::SearchTransition(*map0, kData, *name2, attributes));
+ CHECK_EQ(2, TransitionArray::NumberOfTransitions(map0->raw_transitions()));
+ for (int i = 0; i < 2; i++) {
+ Name* key = TransitionArray::GetKey(map0->raw_transitions(), i);
+ Map* target = TransitionArray::GetTarget(map0->raw_transitions(), i);
+ CHECK((key == *name1 && target == *map1) ||
+ (key == *name2 && target == *map2));
+ }
- DCHECK(transitions->IsSortedNoDuplicates());
+ DCHECK(TransitionArray::IsSortedNoDuplicates(*map0));
}
@@ -160,9 +149,7 @@ TEST(TransitionArray_DifferentFieldNames) {
PropertyAttributes attributes = NONE;
Handle<Map> map0 = Map::Create(isolate, 0);
- CHECK(!map0->HasTransitionArray());
- Handle<TransitionArray> transitions = TransitionArray::Allocate(isolate, 0);
- CHECK(transitions->IsFullTransitionArray());
+ CHECK(map0->raw_transitions()->IsSmi());
for (int i = 0; i < PROPS_COUNT; i++) {
EmbeddedVector<char, 64> buffer;
@@ -175,17 +162,25 @@ TEST(TransitionArray_DifferentFieldNames) {
names[i] = name;
maps[i] = map;
- transitions = transitions->Insert(map0, name, map, PROPERTY_TRANSITION);
- ConnectTransition(map0, transitions, map);
+ TransitionArray::Insert(map0, name, map, PROPERTY_TRANSITION);
}
for (int i = 0; i < PROPS_COUNT; i++) {
- int transition = transitions->Search(kData, *names[i], attributes);
- CHECK_EQ(*names[i], transitions->GetKey(transition));
- CHECK_EQ(*maps[i], transitions->GetTarget(transition));
+ CHECK_EQ(*maps[i], TransitionArray::SearchTransition(
+ *map0, kData, *names[i], attributes));
+ }
+ for (int i = 0; i < PROPS_COUNT; i++) {
+ Name* key = TransitionArray::GetKey(map0->raw_transitions(), i);
+ Map* target = TransitionArray::GetTarget(map0->raw_transitions(), i);
+ for (int j = 0; j < PROPS_COUNT; j++) {
+ if (*names[i] == key) {
+ CHECK_EQ(*maps[i], target);
+ break;
+ }
+ }
}
- DCHECK(transitions->IsSortedNoDuplicates());
+ DCHECK(TransitionArray::IsSortedNoDuplicates(*map0));
}
@@ -196,9 +191,7 @@ TEST(TransitionArray_SameFieldNamesDifferentAttributesSimple) {
Factory* factory = isolate->factory();
Handle<Map> map0 = Map::Create(isolate, 0);
- CHECK(!map0->HasTransitionArray());
- Handle<TransitionArray> transitions = TransitionArray::Allocate(isolate, 0);
- CHECK(transitions->IsFullTransitionArray());
+ CHECK(map0->raw_transitions()->IsSmi());
const int ATTRS_COUNT = (READ_ONLY | DONT_ENUM | DONT_DELETE) + 1;
STATIC_ASSERT(ATTRS_COUNT == 8);
@@ -215,20 +208,20 @@ TEST(TransitionArray_SameFieldNamesDifferentAttributesSimple) {
OMIT_TRANSITION).ToHandleChecked();
attr_maps[i] = map;
- transitions = transitions->Insert(map0, name, map, PROPERTY_TRANSITION);
- ConnectTransition(map0, transitions, map);
+ TransitionArray::Insert(map0, name, map, PROPERTY_TRANSITION);
}
// Ensure that transitions for |name| field are valid.
for (int i = 0; i < ATTRS_COUNT; i++) {
PropertyAttributes attributes = static_cast<PropertyAttributes>(i);
-
- int transition = transitions->Search(kData, *name, attributes);
- CHECK_EQ(*name, transitions->GetKey(transition));
- CHECK_EQ(*attr_maps[i], transitions->GetTarget(transition));
+ CHECK_EQ(*attr_maps[i], TransitionArray::SearchTransition(
+ *map0, kData, *name, attributes));
+ // All transitions use the same key, so this check doesn't need to
+ // care about ordering.
+ CHECK_EQ(*name, TransitionArray::GetKey(map0->raw_transitions(), i));
}
- DCHECK(transitions->IsSortedNoDuplicates());
+ DCHECK(TransitionArray::IsSortedNoDuplicates(*map0));
}
@@ -243,9 +236,7 @@ TEST(TransitionArray_SameFieldNamesDifferentAttributes) {
Handle<Map> maps[PROPS_COUNT];
Handle<Map> map0 = Map::Create(isolate, 0);
- CHECK(!map0->HasTransitionArray());
- Handle<TransitionArray> transitions = TransitionArray::Allocate(isolate, 0);
- CHECK(transitions->IsFullTransitionArray());
+ CHECK(map0->raw_transitions()->IsSmi());
// Some number of fields.
for (int i = 0; i < PROPS_COUNT; i++) {
@@ -259,8 +250,7 @@ TEST(TransitionArray_SameFieldNamesDifferentAttributes) {
names[i] = name;
maps[i] = map;
- transitions = transitions->Insert(map0, name, map, PROPERTY_TRANSITION);
- ConnectTransition(map0, transitions, map);
+ TransitionArray::Insert(map0, name, map, PROPERTY_TRANSITION);
}
const int ATTRS_COUNT = (READ_ONLY | DONT_ENUM | DONT_DELETE) + 1;
@@ -278,25 +268,36 @@ TEST(TransitionArray_SameFieldNamesDifferentAttributes) {
OMIT_TRANSITION).ToHandleChecked();
attr_maps[i] = map;
- transitions = transitions->Insert(map0, name, map, PROPERTY_TRANSITION);
- ConnectTransition(map0, transitions, map);
+ TransitionArray::Insert(map0, name, map, PROPERTY_TRANSITION);
}
// Ensure that transitions for |name| field are valid.
for (int i = 0; i < ATTRS_COUNT; i++) {
- PropertyAttributes attributes = static_cast<PropertyAttributes>(i);
-
- int transition = transitions->Search(kData, *name, attributes);
- CHECK_EQ(*name, transitions->GetKey(transition));
- CHECK_EQ(*attr_maps[i], transitions->GetTarget(transition));
+ PropertyAttributes attr = static_cast<PropertyAttributes>(i);
+ CHECK_EQ(*attr_maps[i],
+ TransitionArray::SearchTransition(*map0, kData, *name, attr));
}
// Ensure that info about the other fields still valid.
- for (int i = 0; i < PROPS_COUNT; i++) {
- int transition = transitions->Search(kData, *names[i], NONE);
- CHECK_EQ(*names[i], transitions->GetKey(transition));
- CHECK_EQ(*maps[i], transitions->GetTarget(transition));
+ CHECK_EQ(PROPS_COUNT + ATTRS_COUNT,
+ TransitionArray::NumberOfTransitions(map0->raw_transitions()));
+ for (int i = 0; i < PROPS_COUNT + ATTRS_COUNT; i++) {
+ Name* key = TransitionArray::GetKey(map0->raw_transitions(), i);
+ Map* target = TransitionArray::GetTarget(map0->raw_transitions(), i);
+ if (key == *name) {
+ // Attributes transition.
+ PropertyAttributes attributes =
+ target->GetLastDescriptorDetails().attributes();
+ CHECK_EQ(*attr_maps[static_cast<int>(attributes)], target);
+ } else {
+ for (int j = 0; j < PROPS_COUNT; j++) {
+ if (*names[j] == key) {
+ CHECK_EQ(*maps[j], target);
+ break;
+ }
+ }
+ }
}
- DCHECK(transitions->IsSortedNoDuplicates());
+ DCHECK(TransitionArray::IsSortedNoDuplicates(*map0));
}
« no previous file with comments | « test/cctest/test-migrations.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698