Commit ac9c9fc5 authored by ishell's avatar ishell Committed by Commit bot

Using PropertyKind in transitions instead of PropertyType.

Review URL: https://codereview.chromium.org/801813002

Cr-Commit-Position: refs/heads/master@{#25802}
parent 9d51f8f5
......@@ -1213,27 +1213,26 @@ bool LayoutDescriptor::IsConsistentWithMap(Map* map) {
bool TransitionArray::IsSortedNoDuplicates(int valid_entries) {
DCHECK(valid_entries == -1);
Name* prev_key = NULL;
bool prev_is_data_property = false;
PropertyKind prev_kind = DATA;
PropertyAttributes prev_attributes = NONE;
uint32_t prev_hash = 0;
for (int i = 0; i < number_of_transitions(); i++) {
Name* key = GetSortedKey(i);
uint32_t hash = key->Hash();
bool is_data_property = false;
PropertyKind kind = DATA;
PropertyAttributes attributes = NONE;
if (!IsSpecialTransition(key)) {
Map* target = GetTarget(i);
PropertyDetails details = GetTargetDetails(key, target);
is_data_property = details.type() == FIELD || details.type() == CONSTANT;
kind = details.kind();
attributes = details.attributes();
} else {
// Duplicate entries are not allowed for non-property transitions.
CHECK_NE(prev_key, key);
}
int cmp =
CompareKeys(prev_key, prev_hash, prev_is_data_property, prev_attributes,
key, hash, is_data_property, attributes);
int cmp = CompareKeys(prev_key, prev_hash, prev_kind, prev_attributes, key,
hash, kind, attributes);
if (cmp >= 0) {
Print();
return false;
......@@ -1241,7 +1240,7 @@ bool TransitionArray::IsSortedNoDuplicates(int valid_entries) {
prev_key = key;
prev_hash = hash;
prev_attributes = attributes;
prev_is_data_property = is_data_property;
prev_kind = kind;
}
return true;
}
......
......@@ -1898,7 +1898,7 @@ Handle<Map> Map::FindTransitionToField(Handle<Map> map, Handle<Name> key) {
DisallowHeapAllocation no_allocation;
if (!map->HasTransitionArray()) return Handle<Map>::null();
TransitionArray* transitions = map->transitions();
int transition = transitions->Search(FIELD, *key, NONE);
int transition = transitions->Search(DATA, *key, NONE);
if (transition == TransitionArray::kNotFound) return Handle<Map>::null();
PropertyDetails details = transitions->GetTargetDetails(transition);
if (details.type() != FIELD) return Handle<Map>::null();
......@@ -3006,7 +3006,7 @@ void Map::LookupDescriptor(JSObject* holder,
void Map::LookupTransition(JSObject* holder, Name* name,
PropertyAttributes attributes,
LookupResult* result) {
int transition_index = this->SearchTransition(FIELD, name, attributes);
int transition_index = this->SearchTransition(DATA, name, attributes);
if (transition_index == TransitionArray::kNotFound) return result->NotFound();
result->TransitionResult(holder, this->GetTransition(transition_index));
}
......@@ -5369,10 +5369,10 @@ int Map::SearchSpecialTransition(Symbol* name) {
}
int Map::SearchTransition(PropertyType type, Name* name,
int Map::SearchTransition(PropertyKind kind, Name* name,
PropertyAttributes attributes) {
if (HasTransitionArray()) {
return transitions()->Search(type, name, attributes);
return transitions()->Search(kind, name, attributes);
}
return TransitionArray::kNotFound;
}
......@@ -5430,7 +5430,7 @@ void Map::set_transitions(TransitionArray* transition_array,
} else {
PropertyDetails details =
TransitionArray::GetTargetDetails(key, target);
new_target_index = transition_array->Search(details.type(), key,
new_target_index = transition_array->Search(details.kind(), key,
details.attributes());
}
DCHECK_NE(TransitionArray::kNotFound, new_target_index);
......
......@@ -2278,14 +2278,14 @@ void Map::DeprecateTransitionTree() {
// the current instance_descriptors to ensure proper sharing of descriptor
// arrays.
// Returns true if the transition target at given key was deprecated.
bool Map::DeprecateTarget(PropertyType type, Name* key,
bool Map::DeprecateTarget(PropertyKind kind, Name* key,
PropertyAttributes attributes,
DescriptorArray* new_descriptors,
LayoutDescriptor* new_layout_descriptor) {
bool transition_target_deprecated = false;
if (HasTransitionArray()) {
TransitionArray* transitions = this->transitions();
int transition = transitions->Search(type, key, attributes);
int transition = transitions->Search(kind, key, attributes);
if (transition != TransitionArray::kNotFound) {
transitions->GetTarget(transition)->DeprecateTransitionTree();
transition_target_deprecated = true;
......@@ -2337,7 +2337,7 @@ Map* Map::FindLastMatchMap(int verbatim,
PropertyDetails details = descriptors->GetDetails(i);
TransitionArray* transitions = current->transitions();
int transition =
transitions->Search(details.type(), name, details.attributes());
transitions->Search(details.kind(), name, details.attributes());
if (transition == TransitionArray::kNotFound) break;
Map* next = transitions->GetTarget(transition);
......@@ -2547,7 +2547,7 @@ Handle<Map> Map::GeneralizeRepresentation(Handle<Map> old_map,
Handle<Map> target_map = root_map;
for (int i = root_nof; i < old_nof; ++i) {
PropertyDetails old_details = old_descriptors->GetDetails(i);
int j = target_map->SearchTransition(old_details.type(),
int j = target_map->SearchTransition(old_details.kind(),
old_descriptors->GetKey(i),
old_details.attributes());
if (j == TransitionArray::kNotFound) break;
......@@ -2615,7 +2615,7 @@ Handle<Map> Map::GeneralizeRepresentation(Handle<Map> old_map,
// Find the last compatible target map in the transition tree.
for (int i = target_nof; i < old_nof; ++i) {
PropertyDetails old_details = old_descriptors->GetDetails(i);
int j = target_map->SearchTransition(old_details.type(),
int j = target_map->SearchTransition(old_details.kind(),
old_descriptors->GetKey(i),
old_details.attributes());
if (j == TransitionArray::kNotFound) break;
......@@ -2762,7 +2762,7 @@ Handle<Map> Map::GeneralizeRepresentation(Handle<Map> old_map,
LayoutDescriptor::New(split_map, new_descriptors, old_nof);
PropertyDetails split_prop_details = old_descriptors->GetDetails(split_nof);
bool transition_target_deprecated = split_map->DeprecateTarget(
split_prop_details.type(), old_descriptors->GetKey(split_nof),
split_prop_details.kind(), old_descriptors->GetKey(split_nof),
split_prop_details.attributes(), *new_descriptors,
*new_layout_descriptor);
......@@ -2859,7 +2859,7 @@ MaybeHandle<Map> Map::TryUpdateInternal(Handle<Map> old_map) {
Map* new_map = root_map;
for (int i = root_nof; i < old_nof; ++i) {
PropertyDetails old_details = old_descriptors->GetDetails(i);
int j = new_map->SearchTransition(old_details.type(),
int j = new_map->SearchTransition(old_details.kind(),
old_descriptors->GetKey(i),
old_details.attributes());
if (j == TransitionArray::kNotFound) return MaybeHandle<Map>();
......@@ -7133,7 +7133,7 @@ Handle<Map> Map::TransitionToDataProperty(Handle<Map> map, Handle<Name> name,
// Migrate to the newest map before storing the property.
map = Update(map);
int index = map->SearchTransition(FIELD, *name, attributes);
int index = map->SearchTransition(DATA, *name, attributes);
if (index != TransitionArray::kNotFound) {
Handle<Map> transition(map->GetTransition(index));
int descriptor = transition->LastAdded();
......@@ -7210,7 +7210,7 @@ Handle<Map> Map::TransitionToAccessorProperty(Handle<Map> map,
? KEEP_INOBJECT_PROPERTIES
: CLEAR_INOBJECT_PROPERTIES;
int index = map->SearchTransition(CALLBACKS, *name, attributes);
int index = map->SearchTransition(ACCESSOR, *name, attributes);
if (index != TransitionArray::kNotFound) {
Handle<Map> transition(map->GetTransition(index));
DescriptorArray* descriptors = transition->instance_descriptors();
......
......@@ -5849,7 +5849,7 @@ class Map: public HeapObject {
inline Map* GetTransition(int transition_index);
inline int SearchSpecialTransition(Symbol* name);
inline int SearchTransition(PropertyType type, Name* name,
inline int SearchTransition(PropertyKind kind, Name* name,
PropertyAttributes attributes);
inline FixedArrayBase* GetInitialElements();
......@@ -6426,7 +6426,7 @@ class Map: public HeapObject {
void ZapTransitions();
void DeprecateTransitionTree();
bool DeprecateTarget(PropertyType type, Name* key,
bool DeprecateTarget(PropertyKind kind, Name* key,
PropertyAttributes attributes,
DescriptorArray* new_descriptors,
LayoutDescriptor* new_layout_descriptor);
......
......@@ -165,16 +165,14 @@ bool TransitionArray::IsSpecialTransition(Name* name) {
#endif
int TransitionArray::CompareKeys(Name* key1, uint32_t hash1,
bool is_data_property1,
int TransitionArray::CompareKeys(Name* key1, uint32_t hash1, PropertyKind kind1,
PropertyAttributes attributes1, Name* key2,
uint32_t hash2, bool is_data_property2,
uint32_t hash2, PropertyKind kind2,
PropertyAttributes attributes2) {
int cmp = CompareNames(key1, hash1, key2, hash2);
if (cmp != 0) return cmp;
return CompareDetails(is_data_property1, attributes1, is_data_property2,
attributes2);
return CompareDetails(kind1, attributes1, kind2, attributes2);
}
......@@ -189,15 +187,12 @@ int TransitionArray::CompareNames(Name* key1, uint32_t hash1, Name* key2,
}
int TransitionArray::CompareDetails(bool is_data_property1,
int TransitionArray::CompareDetails(PropertyKind kind1,
PropertyAttributes attributes1,
bool is_data_property2,
PropertyKind kind2,
PropertyAttributes attributes2) {
if (is_data_property1 != is_data_property2) {
return static_cast<int>(is_data_property1) <
static_cast<int>(is_data_property2)
? -1
: 1;
if (kind1 != kind2) {
return static_cast<int>(kind1) < static_cast<int>(kind2) ? -1 : 1;
}
if (attributes1 != attributes2) {
......
......@@ -105,7 +105,7 @@ Handle<TransitionArray> TransitionArray::Insert(Handle<Map> map,
is_special_transition
? map->transitions()->SearchSpecial(Symbol::cast(*name),
&insertion_index)
: map->transitions()->Search(details.type(), *name,
: map->transitions()->Search(details.kind(), *name,
details.attributes(), &insertion_index);
if (index == kNotFound) {
++new_nof;
......@@ -157,7 +157,7 @@ Handle<TransitionArray> TransitionArray::Insert(Handle<Map> map,
index = is_special_transition ? map->transitions()->SearchSpecial(
Symbol::cast(*name), &insertion_index)
: map->transitions()->Search(
details.type(), *name,
details.kind(), *name,
details.attributes(), &insertion_index);
if (index == kNotFound) {
++new_nof;
......@@ -189,22 +189,18 @@ Handle<TransitionArray> TransitionArray::Insert(Handle<Map> map,
}
int TransitionArray::SearchDetails(int transition, PropertyType type,
int TransitionArray::SearchDetails(int transition, PropertyKind kind,
PropertyAttributes attributes,
int* out_insertion_index) {
int nof_transitions = number_of_transitions();
DCHECK(transition < nof_transitions);
Name* key = GetKey(transition);
bool is_data = type == FIELD || type == CONSTANT;
for (; transition < nof_transitions && GetKey(transition) == key;
transition++) {
Map* target = GetTarget(transition);
PropertyDetails target_details = GetTargetDetails(key, target);
bool target_is_data =
target_details.type() == FIELD || target_details.type() == CONSTANT;
int cmp = CompareDetails(is_data, attributes, target_is_data,
int cmp = CompareDetails(kind, attributes, target_details.kind(),
target_details.attributes());
if (cmp == 0) {
return transition;
......@@ -217,13 +213,13 @@ int TransitionArray::SearchDetails(int transition, PropertyType type,
}
int TransitionArray::Search(PropertyType type, Name* name,
int TransitionArray::Search(PropertyKind kind, Name* name,
PropertyAttributes attributes,
int* out_insertion_index) {
int transition = SearchName(name, out_insertion_index);
if (transition == kNotFound) {
return kNotFound;
}
return SearchDetails(transition, type, attributes, out_insertion_index);
return SearchDetails(transition, kind, attributes, out_insertion_index);
}
} } // namespace v8::internal
......@@ -98,8 +98,8 @@ class TransitionArray: public FixedArray {
static Handle<TransitionArray> Insert(Handle<Map> map, Handle<Name> name,
Handle<Map> target,
SimpleTransitionFlag flag);
// Search a transition for a given type, property name and attributes.
int Search(PropertyType type, Name* name, PropertyAttributes attributes,
// Search a transition for a given kind, property name and attributes.
int Search(PropertyKind kind, Name* name, PropertyAttributes attributes,
int* out_insertion_index = NULL);
// Search a non-property transition (like elements kind, observe or frozen
......@@ -216,15 +216,14 @@ class TransitionArray: public FixedArray {
// Search a first transition for a given property name.
inline int SearchName(Name* name, int* out_insertion_index = NULL);
int SearchDetails(int transition, PropertyType type,
int SearchDetails(int transition, PropertyKind kind,
PropertyAttributes attributes, int* out_insertion_index);
// Compares two tuples <key, is_data_property, attributes>, returns -1 if
// Compares two tuples <key, kind, attributes>, returns -1 if
// tuple1 is "less" than tuple2, 0 if tuple1 equal to tuple2 and 1 otherwise.
static inline int CompareKeys(Name* key1, uint32_t hash1,
bool is_data_property1,
static inline int CompareKeys(Name* key1, uint32_t hash1, PropertyKind kind1,
PropertyAttributes attributes1, Name* key2,
uint32_t hash2, bool is_data_property2,
uint32_t hash2, PropertyKind kind2,
PropertyAttributes attributes2);
// Compares keys, returns -1 if key1 is "less" than key2,
......@@ -234,9 +233,9 @@ class TransitionArray: public FixedArray {
// Compares two details, returns -1 if details1 is "less" than details2,
// 0 if details1 equal to details2 and 1 otherwise.
static inline int CompareDetails(bool is_data_property1,
static inline int CompareDetails(PropertyKind kind1,
PropertyAttributes attributes1,
bool is_data_property2,
PropertyKind kind2,
PropertyAttributes attributes2);
inline void NoIncrementalWriteBarrierSet(int transition_number,
......
......@@ -59,7 +59,7 @@ TEST(TransitionArray_SimpleFieldTransitions) {
transitions->Insert(map0, name1, map1, SIMPLE_PROPERTY_TRANSITION);
ConnectTransition(map0, transitions, map1);
CHECK(transitions->IsSimpleTransition());
transition = transitions->Search(FIELD, *name1, attributes);
transition = transitions->Search(DATA, *name1, attributes);
CHECK_EQ(TransitionArray::kSimpleTransitionIndex, transition);
CHECK_EQ(*name1, transitions->GetKey(transition));
CHECK_EQ(*map1, transitions->GetTarget(transition));
......@@ -69,11 +69,11 @@ TEST(TransitionArray_SimpleFieldTransitions) {
ConnectTransition(map0, transitions, map2);
CHECK(transitions->IsFullTransitionArray());
transition = transitions->Search(FIELD, *name1, attributes);
transition = transitions->Search(DATA, *name1, attributes);
CHECK_EQ(*name1, transitions->GetKey(transition));
CHECK_EQ(*map1, transitions->GetTarget(transition));
transition = transitions->Search(FIELD, *name2, attributes);
transition = transitions->Search(DATA, *name2, attributes);
CHECK_EQ(*name2, transitions->GetKey(transition));
CHECK_EQ(*map2, transitions->GetTarget(transition));
......@@ -109,7 +109,7 @@ TEST(TransitionArray_FullFieldTransitions) {
transitions = transitions->Insert(map0, name1, map1, PROPERTY_TRANSITION);
ConnectTransition(map0, transitions, map1);
CHECK(transitions->IsFullTransitionArray());
transition = transitions->Search(FIELD, *name1, attributes);
transition = transitions->Search(DATA, *name1, attributes);
CHECK_EQ(*name1, transitions->GetKey(transition));
CHECK_EQ(*map1, transitions->GetTarget(transition));
......@@ -117,11 +117,11 @@ TEST(TransitionArray_FullFieldTransitions) {
ConnectTransition(map0, transitions, map2);
CHECK(transitions->IsFullTransitionArray());
transition = transitions->Search(FIELD, *name1, attributes);
transition = transitions->Search(DATA, *name1, attributes);
CHECK_EQ(*name1, transitions->GetKey(transition));
CHECK_EQ(*map1, transitions->GetTarget(transition));
transition = transitions->Search(FIELD, *name2, attributes);
transition = transitions->Search(DATA, *name2, attributes);
CHECK_EQ(*name2, transitions->GetKey(transition));
CHECK_EQ(*map2, transitions->GetTarget(transition));
......@@ -161,7 +161,7 @@ TEST(TransitionArray_DifferentFieldNames) {
}
for (int i = 0; i < PROPS_COUNT; i++) {
int transition = transitions->Search(FIELD, *names[i], attributes);
int transition = transitions->Search(DATA, *names[i], attributes);
CHECK_EQ(*names[i], transitions->GetKey(transition));
CHECK_EQ(*maps[i], transitions->GetTarget(transition));
}
......@@ -204,7 +204,7 @@ TEST(TransitionArray_SameFieldNamesDifferentAttributesSimple) {
for (int i = 0; i < ATTRS_COUNT; i++) {
PropertyAttributes attributes = static_cast<PropertyAttributes>(i);
int transition = transitions->Search(FIELD, *name, attributes);
int transition = transitions->Search(DATA, *name, attributes);
CHECK_EQ(*name, transitions->GetKey(transition));
CHECK_EQ(*attr_maps[i], transitions->GetTarget(transition));
}
......@@ -267,14 +267,14 @@ TEST(TransitionArray_SameFieldNamesDifferentAttributes) {
for (int i = 0; i < ATTRS_COUNT; i++) {
PropertyAttributes attributes = static_cast<PropertyAttributes>(i);
int transition = transitions->Search(FIELD, *name, attributes);
int transition = transitions->Search(DATA, *name, attributes);
CHECK_EQ(*name, transitions->GetKey(transition));
CHECK_EQ(*attr_maps[i], transitions->GetTarget(transition));
}
// Ensure that info about the other fields still valid.
for (int i = 0; i < PROPS_COUNT; i++) {
int transition = transitions->Search(FIELD, *names[i], NONE);
int transition = transitions->Search(DATA, *names[i], NONE);
CHECK_EQ(*names[i], transitions->GetKey(transition));
CHECK_EQ(*maps[i], transitions->GetTarget(transition));
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment