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

Unified Diff: src/objects.h

Issue 1002703002: remove DeletedField from PropertyDetails (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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 | « src/lookup-inl.h ('k') | src/objects.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects.h
diff --git a/src/objects.h b/src/objects.h
index ab7778ffba5c302580064068085c476833b76cde..76b64f6bb532ac581034b760c37390aa82751909 100644
--- a/src/objects.h
+++ b/src/objects.h
@@ -3527,6 +3527,9 @@ class StringTable: public HashTable<StringTable,
};
+enum class DictionaryEntryType { kObjects, kCells };
+
+
template <typename Derived, typename Shape, typename Key>
class Dictionary: public HashTable<Derived, Shape, Key> {
protected:
@@ -3555,9 +3558,6 @@ class Dictionary: public HashTable<Derived, Shape, Key> {
this->set(DerivedHashTable::EntryToIndex(entry) + 2, value.AsSmi());
}
- // Sorting support
- void CopyValuesTo(FixedArray* elements);
-
// Delete a property from the dictionary.
static Handle<Object> DeleteProperty(Handle<Derived> dictionary, int entry);
@@ -3568,27 +3568,82 @@ class Dictionary: public HashTable<Derived, Shape, Key> {
return DerivedHashTable::Shrink(dictionary, key);
}
+ // Sorting support
+ // TODO(dcarney): templatize or move to SeededNumberDictionary
+ void CopyValuesTo(FixedArray* elements);
+
// Returns the number of elements in the dictionary filtering out properties
// with the specified attributes.
+ template <DictionaryEntryType type>
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.
- int NumberOfEnumElements();
+ template <DictionaryEntryType type>
+ int NumberOfEnumElements() {
+ return NumberOfElementsFilterAttributes<type>(
+ 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,
// non-configurable, non-enumerable, or have getters/setters.
+ template <DictionaryEntryType type>
bool HasComplexElements();
+ bool HasComplexElements(Object* holder) {
+ if (holder->IsGlobalObject()) {
+ return HasComplexElements<DictionaryEntryType::kCells>();
+ } else {
+ return HasComplexElements<DictionaryEntryType::kObjects>();
+ }
+ }
enum SortMode { UNSORTED, SORTED };
+
// Copies keys to preallocated fixed array.
- void CopyKeysTo(FixedArray* storage,
- PropertyAttributes filter,
+ template <DictionaryEntryType type>
+ void CopyKeysTo(FixedArray* storage, PropertyAttributes filter,
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.
- void CopyKeysTo(FixedArray* storage,
- int index,
- PropertyAttributes filter,
+ template <DictionaryEntryType type>
+ void CopyKeysTo(FixedArray* storage, int index, PropertyAttributes filter,
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);
+ }
+ }
// Accessors for next enumeration index.
void SetNextEnumerationIndex(int index) {
@@ -3681,7 +3736,16 @@ class NameDictionary: public Dictionary<NameDictionary,
DECLARE_CAST(NameDictionary)
// Copies enumerable keys to preallocated fixed array.
+ template <DictionaryEntryType type>
void CopyEnumKeysTo(FixedArray* storage);
+ void CopyEnumKeysTo(Object* holder, FixedArray* storage) {
+ if (holder->IsGlobalObject()) {
+ return CopyEnumKeysTo<DictionaryEntryType::kCells>(storage);
+ } else {
+ return CopyEnumKeysTo<DictionaryEntryType::kObjects>(storage);
+ }
+ }
+
inline static Handle<FixedArray> DoGenerateNewEnumerationIndices(
Handle<NameDictionary> dictionary);
« no previous file with comments | « src/lookup-inl.h ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698