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

Enum DictionaryEntryType removed.

Dictionary customization should be implemented in respective shape class.

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

Cr-Commit-Position: refs/heads/master@{#28738}
parent 144be2c4
...@@ -7210,6 +7210,13 @@ Handle<FixedArray> NameDictionary::DoGenerateNewEnumerationIndices( ...@@ -7210,6 +7210,13 @@ Handle<FixedArray> NameDictionary::DoGenerateNewEnumerationIndices(
} }
template <typename Dictionary>
bool GlobalDictionaryShape::IsDeleted(Dictionary* dict, int entry) {
DCHECK(dict->ValueAt(entry)->IsPropertyCell());
return PropertyCell::cast(dict->ValueAt(entry))->value()->IsTheHole();
}
bool ObjectHashTableShape::IsMatch(Handle<Object> key, Object* other) { bool ObjectHashTableShape::IsMatch(Handle<Object> key, Object* other) {
return key->SameValue(other); return key->SameValue(other);
} }
......
This diff is collapsed.
...@@ -3598,9 +3598,6 @@ class StringTable: public HashTable<StringTable, ...@@ -3598,9 +3598,6 @@ class StringTable: public HashTable<StringTable,
}; };
enum class DictionaryEntryType { kObjects, kCells };
template <typename Derived, typename Shape, typename Key> template <typename Derived, typename Shape, typename Key>
class Dictionary: public HashTable<Derived, Shape, Key> { class Dictionary: public HashTable<Derived, Shape, Key> {
typedef HashTable<Derived, Shape, Key> DerivedHashTable; typedef HashTable<Derived, Shape, Key> DerivedHashTable;
...@@ -3628,6 +3625,11 @@ class Dictionary: public HashTable<Derived, Shape, Key> { ...@@ -3628,6 +3625,11 @@ class Dictionary: public HashTable<Derived, Shape, Key> {
this->set(Derived::EntryToIndex(entry) + 2, value.AsSmi()); this->set(Derived::EntryToIndex(entry) + 2, value.AsSmi());
} }
// Returns true if property at given entry is deleted.
bool IsDeleted(int entry) {
return Shape::IsDeleted(static_cast<Derived*>(this), entry);
}
// Delete a property from the dictionary. // Delete a property from the dictionary.
static Handle<Object> DeleteProperty(Handle<Derived> dictionary, int entry); static Handle<Object> DeleteProperty(Handle<Derived> dictionary, int entry);
...@@ -3644,87 +3646,30 @@ class Dictionary: public HashTable<Derived, Shape, Key> { ...@@ -3644,87 +3646,30 @@ class Dictionary: public HashTable<Derived, Shape, Key> {
// Returns the number of elements in the dictionary filtering out properties // Returns the number of elements in the dictionary filtering out properties
// with the specified attributes. // with the specified attributes.
template <DictionaryEntryType type>
int NumberOfElementsFilterAttributes(PropertyAttributes filter); int NumberOfElementsFilterAttributes(PropertyAttributes filter);
int NumberOfElementsFilterAttributes(Object* holder,
PropertyAttributes filter) {
if (holder->IsGlobalObject()) {
return NumberOfElementsFilterAttributes<DictionaryEntryType::kCells>(
filter);
} else {
return NumberOfElementsFilterAttributes<DictionaryEntryType::kObjects>(
filter);
}
}
// Returns the number of enumerable elements in the dictionary. // Returns the number of enumerable elements in the dictionary.
template <DictionaryEntryType type>
int NumberOfEnumElements() { int NumberOfEnumElements() {
return NumberOfElementsFilterAttributes<type>( return NumberOfElementsFilterAttributes(
static_cast<PropertyAttributes>(DONT_ENUM | SYMBOLIC)); static_cast<PropertyAttributes>(DONT_ENUM | SYMBOLIC));
} }
int NumberOfEnumElements(Object* holder) {
if (holder->IsGlobalObject()) {
return NumberOfEnumElements<DictionaryEntryType::kCells>();
} else {
return NumberOfEnumElements<DictionaryEntryType::kObjects>();
}
}
// Returns true if the dictionary contains any elements that are non-writable, // Returns true if the dictionary contains any elements that are non-writable,
// non-configurable, non-enumerable, or have getters/setters. // non-configurable, non-enumerable, or have getters/setters.
template <DictionaryEntryType type>
bool HasComplexElements(); bool HasComplexElements();
bool HasComplexElements(Object* holder) {
if (holder->IsGlobalObject()) {
return HasComplexElements<DictionaryEntryType::kCells>();
} else {
return HasComplexElements<DictionaryEntryType::kObjects>();
}
}
enum SortMode { UNSORTED, SORTED }; enum SortMode { UNSORTED, SORTED };
// Copies keys to preallocated fixed array. // Copies keys to preallocated fixed array.
template <DictionaryEntryType type>
void CopyKeysTo(FixedArray* storage, PropertyAttributes filter, void CopyKeysTo(FixedArray* storage, PropertyAttributes filter,
SortMode sort_mode); SortMode sort_mode);
void CopyKeysTo(Object* holder, FixedArray* storage,
PropertyAttributes filter, SortMode sort_mode) {
if (holder->IsGlobalObject()) {
return CopyKeysTo<DictionaryEntryType::kCells>(storage, filter,
sort_mode);
} else {
return CopyKeysTo<DictionaryEntryType::kObjects>(storage, filter,
sort_mode);
}
}
// Fill in details for properties into storage. // Fill in details for properties into storage.
template <DictionaryEntryType type>
void CopyKeysTo(FixedArray* storage, int index, PropertyAttributes filter, void CopyKeysTo(FixedArray* storage, int index, PropertyAttributes filter,
SortMode sort_mode); SortMode sort_mode);
void CopyKeysTo(Object* holder, FixedArray* storage, int index,
PropertyAttributes filter, SortMode sort_mode) {
if (holder->IsGlobalObject()) {
return CopyKeysTo<DictionaryEntryType::kCells>(storage, index, filter,
sort_mode);
} else {
return CopyKeysTo<DictionaryEntryType::kObjects>(storage, index, filter,
sort_mode);
}
}
// Copies enumerable keys to preallocated fixed array. // Copies enumerable keys to preallocated fixed array.
template <DictionaryEntryType type>
void CopyEnumKeysTo(FixedArray* storage); void CopyEnumKeysTo(FixedArray* storage);
void CopyEnumKeysTo(Object* holder, FixedArray* storage) {
if (holder->IsGlobalObject()) {
return CopyEnumKeysTo<DictionaryEntryType::kCells>(storage);
} else {
return CopyEnumKeysTo<DictionaryEntryType::kObjects>(storage);
}
}
// Accessors for next enumeration index. // Accessors for next enumeration index.
void SetNextEnumerationIndex(int index) { void SetNextEnumerationIndex(int index) {
...@@ -3806,7 +3751,17 @@ class NameDictionaryBase : public Dictionary<Derived, Shape, Handle<Name> > { ...@@ -3806,7 +3751,17 @@ class NameDictionaryBase : public Dictionary<Derived, Shape, Handle<Name> > {
}; };
class NameDictionaryShape : public BaseShape<Handle<Name> > { template <typename Key>
class BaseDictionaryShape : public BaseShape<Key> {
public:
template <typename Dictionary>
static bool IsDeleted(Dictionary* dict, int entry) {
return false;
}
};
class NameDictionaryShape : public BaseDictionaryShape<Handle<Name> > {
public: public:
static inline bool IsMatch(Handle<Name> key, Object* other); static inline bool IsMatch(Handle<Name> key, Object* other);
static inline uint32_t Hash(Handle<Name> key); static inline uint32_t Hash(Handle<Name> key);
...@@ -3834,6 +3789,9 @@ class NameDictionary ...@@ -3834,6 +3789,9 @@ class NameDictionary
class GlobalDictionaryShape : public NameDictionaryShape { class GlobalDictionaryShape : public NameDictionaryShape {
public: public:
static const int kEntrySize = 3; // Overrides NameDictionaryShape::kEntrySize static const int kEntrySize = 3; // Overrides NameDictionaryShape::kEntrySize
template <typename Dictionary>
static bool IsDeleted(Dictionary* dict, int entry);
}; };
...@@ -3844,7 +3802,7 @@ class GlobalDictionary ...@@ -3844,7 +3802,7 @@ class GlobalDictionary
}; };
class NumberDictionaryShape : public BaseShape<uint32_t> { class NumberDictionaryShape : public BaseDictionaryShape<uint32_t> {
public: public:
static inline bool IsMatch(uint32_t key, Object* other); static inline bool IsMatch(uint32_t key, Object* other);
static inline Handle<Object> AsHandle(Isolate* isolate, uint32_t key); static inline Handle<Object> AsHandle(Isolate* isolate, uint32_t key);
......
...@@ -1293,8 +1293,7 @@ RUNTIME_FUNCTION(Runtime_HasComplexElements) { ...@@ -1293,8 +1293,7 @@ RUNTIME_FUNCTION(Runtime_HasComplexElements) {
return isolate->heap()->true_value(); return isolate->heap()->true_value();
} }
if (!current->HasDictionaryElements()) continue; if (!current->HasDictionaryElements()) continue;
if (current->element_dictionary() if (current->element_dictionary()->HasComplexElements()) {
->HasComplexElements<DictionaryEntryType::kObjects>()) {
return isolate->heap()->true_value(); return isolate->heap()->true_value();
} }
} }
......
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