diff --git a/src/objects-inl.h b/src/objects-inl.h index 63dfce5700..be6d5e66d7 100644 --- a/src/objects-inl.h +++ b/src/objects-inl.h @@ -2945,21 +2945,20 @@ Map* BaseShape::GetMap(Isolate* isolate) { return isolate->heap()->hash_table_map(); } -template -int HashTable::FindEntry(Key key) { +template +int HashTable::FindEntry(Key key) { return FindEntry(GetIsolate(), key); } - -template -int HashTable::FindEntry(Isolate* isolate, Key key) { +template +int HashTable::FindEntry(Isolate* isolate, Key key) { return FindEntry(isolate, key, HashTable::Hash(key)); } // Find entry for key otherwise return kNotFound. -template -int HashTable::FindEntry(Isolate* isolate, Key key, - int32_t hash) { +template +int HashTable::FindEntry(Isolate* isolate, Key key, + int32_t hash) { uint32_t capacity = Capacity(); uint32_t entry = FirstProbe(hash, capacity); uint32_t count = 1; @@ -2977,13 +2976,13 @@ int HashTable::FindEntry(Isolate* isolate, Key key, return kNotFound; } -template -bool HashTable::Has(Key key) { +template +bool HashTable::Has(Key key) { return FindEntry(key) != kNotFound; } -template -bool HashTable::Has(Isolate* isolate, Key key) { +template +bool HashTable::Has(Isolate* isolate, Key key) { return FindEntry(isolate, key) != kNotFound; } @@ -3175,17 +3174,15 @@ int HandlerTable::NumberOfRangeEntries() const { return length() / kRangeEntrySize; } -template -HashTable* -HashTable::cast(Object* obj) { +template +HashTable* HashTable::cast(Object* obj) { SLOW_DCHECK(obj->IsHashTable()); return reinterpret_cast(obj); } - -template -const HashTable* -HashTable::cast(const Object* obj) { +template +const HashTable* HashTable::cast( + const Object* obj) { SLOW_DCHECK(obj->IsHashTable()); return reinterpret_cast(obj); } @@ -6930,20 +6927,16 @@ bool AccessorPair::IsJSAccessor(Object* obj) { return obj->IsCallable() || obj->IsUndefined(GetIsolate()); } - -template -void Dictionary::SetEntry(int entry, - Handle key, - Handle value) { +template +void Dictionary::SetEntry(int entry, Handle key, + Handle value) { this->SetEntry(entry, key, value, PropertyDetails(Smi::kZero)); } - -template -void Dictionary::SetEntry(int entry, - Handle key, - Handle value, - PropertyDetails details) { +template +void Dictionary::SetEntry(int entry, Handle key, + Handle value, + PropertyDetails details) { Shape::SetEntry(static_cast(this), entry, key, value, details); } diff --git a/src/objects.cc b/src/objects.cc index 974f72813f..f4b1bcd893 100644 --- a/src/objects.cc +++ b/src/objects.cc @@ -15841,8 +15841,8 @@ int JSObject::GetFastElementsUsage() { // together, so even though this function belongs in objects-debug.cc, // we keep it here instead to satisfy certain compilers. #ifdef OBJECT_PRINT -template -void Dictionary::Print(std::ostream& os) { // NOLINT +template +void Dictionary::Print(std::ostream& os) { // NOLINT Isolate* isolate = this->GetIsolate(); int capacity = this->Capacity(); for (int i = 0; i < capacity; i++) { @@ -15859,8 +15859,8 @@ void Dictionary::Print(std::ostream& os) { // NOLINT } } } -template -void Dictionary::Print() { +template +void Dictionary::Print() { OFStream os(stdout); Print(os); } @@ -16365,26 +16365,22 @@ class InternalizedStringKey : public HashTableKey { Handle string_; }; - -template -void HashTable::IteratePrefix(ObjectVisitor* v) { +template +void HashTable::IteratePrefix(ObjectVisitor* v) { BodyDescriptorBase::IteratePointers(this, 0, kElementsStartOffset, v); } - -template -void HashTable::IterateElements(ObjectVisitor* v) { +template +void HashTable::IterateElements(ObjectVisitor* v) { BodyDescriptorBase::IteratePointers(this, kElementsStartOffset, kHeaderSize + length() * kPointerSize, v); } - -template -Handle HashTable::New( - Isolate* isolate, - int at_least_space_for, - MinimumCapacity capacity_option, - PretenureFlag pretenure) { +template +Handle HashTable::New(Isolate* isolate, + int at_least_space_for, + MinimumCapacity capacity_option, + PretenureFlag pretenure) { DCHECK(0 <= at_least_space_for); DCHECK_IMPLIES(capacity_option == USE_CUSTOM_MINIMUM_CAPACITY, base::bits::IsPowerOfTwo32(at_least_space_for)); @@ -16398,10 +16394,9 @@ Handle HashTable::New( return New(isolate, capacity, pretenure); } -template -Handle HashTable::New(Isolate* isolate, - int capacity, - PretenureFlag pretenure) { +template +Handle HashTable::New(Isolate* isolate, int capacity, + PretenureFlag pretenure) { Factory* factory = isolate->factory(); int length = EntryToIndex(capacity); Handle array = factory->NewFixedArray(length, pretenure); @@ -16445,11 +16440,8 @@ int NameDictionaryBase::FindEntry(Handle key) { return Derived::kNotFound; } - -template -void HashTable::Rehash( - Handle new_table, - Key key) { +template +void HashTable::Rehash(Handle new_table, Key key) { DCHECK(NumberOfElements() < new_table->Capacity()); DisallowHeapAllocation no_gc; @@ -16483,13 +16475,9 @@ void HashTable::Rehash( new_table->SetNumberOfDeletedElements(0); } - -template -uint32_t HashTable::EntryForProbe( - Key key, - Object* k, - int probe, - uint32_t expected) { +template +uint32_t HashTable::EntryForProbe(Key key, Object* k, int probe, + uint32_t expected) { uint32_t hash = this->HashForObject(key, k); uint32_t capacity = this->Capacity(); uint32_t entry = FirstProbe(hash, capacity); @@ -16500,11 +16488,9 @@ uint32_t HashTable::EntryForProbe( return entry; } - -template -void HashTable::Swap(uint32_t entry1, - uint32_t entry2, - WriteBarrierMode mode) { +template +void HashTable::Swap(uint32_t entry1, uint32_t entry2, + WriteBarrierMode mode) { int index1 = EntryToIndex(entry1); int index2 = EntryToIndex(entry2); Object* temp[Shape::kEntrySize]; @@ -16519,9 +16505,8 @@ void HashTable::Swap(uint32_t entry1, } } - -template -void HashTable::Rehash(Key key) { +template +void HashTable::Rehash(Key key) { DisallowHeapAllocation no_gc; WriteBarrierMode mode = GetWriteBarrierMode(no_gc); Isolate* isolate = GetIsolate(); @@ -16562,13 +16547,9 @@ void HashTable::Rehash(Key key) { SetNumberOfDeletedElements(0); } - -template -Handle HashTable::EnsureCapacity( - Handle table, - int n, - Key key, - PretenureFlag pretenure) { +template +Handle HashTable::EnsureCapacity( + Handle table, int n, Key key, PretenureFlag pretenure) { if (table->HasSufficientCapacityToAdd(n)) return table; Isolate* isolate = table->GetIsolate(); @@ -16587,8 +16568,8 @@ Handle HashTable::EnsureCapacity( return new_table; } -template -bool HashTable::HasSufficientCapacityToAdd( +template +bool HashTable::HasSufficientCapacityToAdd( int number_of_additional_elements) { int capacity = Capacity(); int nof = NumberOfElements() + number_of_additional_elements; @@ -16603,10 +16584,9 @@ bool HashTable::HasSufficientCapacityToAdd( return false; } - -template -Handle HashTable::Shrink(Handle table, - Key key) { +template +Handle HashTable::Shrink(Handle table, + Key key) { int capacity = table->Capacity(); int nof = table->NumberOfElements(); @@ -16635,9 +16615,8 @@ Handle HashTable::Shrink(Handle table, return new_table; } - -template -uint32_t HashTable::FindInsertionEntry(uint32_t hash) { +template +uint32_t HashTable::FindInsertionEntry(uint32_t hash) { uint32_t capacity = Capacity(); uint32_t entry = FirstProbe(hash, capacity); uint32_t count = 1; @@ -16655,199 +16634,181 @@ uint32_t HashTable::FindInsertionEntry(uint32_t hash) { // Force instantiation of template instances class. // Please note this list is compiler dependent. -template class HashTable; +template class HashTable; -template class HashTable; +template class HashTable; -template class HashTable >; +template class HashTable; -template class HashTable, Handle >; +template class HashTable>; -template class Dictionary >; +template class Dictionary; -template class Dictionary >; +template class Dictionary; template class EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE) - HashTable; + HashTable; template class EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE) - Dictionary; + Dictionary; template class Dictionary; + UnseededNumberDictionaryShape>; template Handle -Dictionary::New( +Dictionary::New( Isolate*, int at_least_space_for, PretenureFlag pretenure, MinimumCapacity capacity_option); template Handle -Dictionary::NewEmpty(Isolate*, PretenureFlag pretenure); +Dictionary::NewEmpty( + Isolate*, PretenureFlag pretenure); template Handle -Dictionary::NewEmpty(Isolate*, PretenureFlag pretenure); +Dictionary::NewEmpty( + Isolate*, PretenureFlag pretenure); template Handle -Dictionary::New(Isolate*, int at_least_space_for, - PretenureFlag pretenure, - MinimumCapacity capacity_option); +Dictionary::New( + Isolate*, int at_least_space_for, PretenureFlag pretenure, + MinimumCapacity capacity_option); template Handle -Dictionary>::New( +Dictionary::New( Isolate*, int n, PretenureFlag pretenure, MinimumCapacity capacity_option); template Handle -Dictionary>::NewEmpty( +Dictionary::NewEmpty( Isolate*, PretenureFlag pretenure); template Handle -Dictionary>::New( +Dictionary::New( Isolate*, int n, PretenureFlag pretenure, MinimumCapacity capacity_option); template Handle -Dictionary:: - AtPut(Handle, uint32_t, Handle); + Dictionary::AtPut( + Handle, uint32_t, Handle); template Handle -Dictionary:: - AtPut(Handle, uint32_t, Handle); + Dictionary::AtPut( + Handle, uint32_t, Handle); template Object* -Dictionary:: - SlowReverseLookup(Object* value); +Dictionary::SlowReverseLookup(Object* value); -template Object* -Dictionary >:: - SlowReverseLookup(Object* value); +template Object* Dictionary< + NameDictionary, NameDictionaryShape>::SlowReverseLookup(Object* value); template Handle -Dictionary >::DeleteProperty( +Dictionary::DeleteProperty( Handle, int); template Handle -Dictionary::DeleteProperty(Handle, int); +Dictionary::DeleteProperty( + Handle, int); template Handle -Dictionary::DeleteProperty(Handle, int); +Dictionary:: + DeleteProperty(Handle, int); template Handle -HashTable >:: - New(Isolate*, int, MinimumCapacity, PretenureFlag); +HashTable::New(Isolate*, int, + MinimumCapacity, + PretenureFlag); -template Handle HashTable>::New(Isolate*, int n, - MinimumCapacity, - PretenureFlag); +template Handle +HashTable::New(Isolate*, int n, + MinimumCapacity, + PretenureFlag); template Handle -HashTable >:: - Shrink(Handle, Handle); + HashTable::Shrink( + Handle, Handle); template Handle - HashTable::Shrink(Handle, uint32_t); + HashTable::Shrink( + Handle, uint32_t); template Handle -Dictionary>::Add( - Handle, Handle, Handle, PropertyDetails, - int*); +Dictionary::Add(Handle, + Handle, + Handle, + PropertyDetails, int*); template Handle -Dictionary>::Add( +Dictionary::Add( Handle, Handle, Handle, PropertyDetails, int*); template Handle -Dictionary::Add( +Dictionary::Add( Handle, uint32_t, Handle, PropertyDetails, int*); template Handle -Dictionary::Add(Handle, uint32_t, - Handle, PropertyDetails, int*); +Dictionary::Add( + Handle, uint32_t, Handle, PropertyDetails, + int*); template Handle -Dictionary:: - EnsureCapacity(Handle, int, uint32_t); +Dictionary::EnsureCapacity( + Handle, int, uint32_t); template Handle -Dictionary:: +Dictionary:: EnsureCapacity(Handle, int, uint32_t); -template void Dictionary >::SetRequiresCopyOnCapacityChange(); +template void Dictionary< + NameDictionary, NameDictionaryShape>::SetRequiresCopyOnCapacityChange(); template Handle -Dictionary >:: - EnsureCapacity(Handle, int, Handle); +Dictionary::EnsureCapacity( + Handle, int, Handle); template int NameDictionaryBase::FindEntry( Handle); -template int Dictionary>::NumberOfEnumerableProperties(); +template int Dictionary::NumberOfEnumerableProperties(); -template int Dictionary>::NumberOfEnumerableProperties(); +template int +Dictionary::NumberOfEnumerableProperties(); template void -Dictionary>:: - CopyEnumKeysTo(Handle>> - dictionary, - Handle storage, KeyCollectionMode mode, - KeyAccumulator* accumulator); +Dictionary::CopyEnumKeysTo( + Handle> dictionary, + Handle storage, KeyCollectionMode mode, + KeyAccumulator* accumulator); -template void -Dictionary>::CopyEnumKeysTo( - Handle>> - dictionary, +template void Dictionary::CopyEnumKeysTo( + Handle> dictionary, Handle storage, KeyCollectionMode mode, KeyAccumulator* accumulator); template Handle -Dictionary>:: - IterationIndices( - Handle< - Dictionary>> - dictionary); +Dictionary::IterationIndices( + Handle> dictionary); template void -Dictionary>:: - CollectKeysTo(Handle>> - dictionary, - KeyAccumulator* keys); +Dictionary::CollectKeysTo( + Handle> dictionary, + KeyAccumulator* keys); template Handle -Dictionary>::IterationIndices( - Handle>> - dictionary); -template void -Dictionary>::CollectKeysTo( - Handle>> - dictionary, +Dictionary::IterationIndices( + Handle> dictionary); +template void Dictionary::CollectKeysTo( + Handle> dictionary, KeyAccumulator* keys); template int -Dictionary::AddEntry(Handle dictionary, - uint32_t key, Handle value, - PropertyDetails details, uint32_t hash); +Dictionary::AddEntry( + Handle dictionary, uint32_t key, + Handle value, PropertyDetails details, uint32_t hash); -template int Dictionary::NumberOfEnumerableProperties(); +template int +Dictionary::NumberOfEnumerableProperties(); Handle JSObject::PrepareSlowElementsForSort( Handle object, uint32_t limit) { @@ -18050,8 +18011,8 @@ void CompilationCacheTable::Remove(Object* value) { return; } -template -Handle Dictionary::New( +template +Handle Dictionary::New( Isolate* isolate, int at_least_space_for, PretenureFlag pretenure, MinimumCapacity capacity_option) { DCHECK(0 <= at_least_space_for); @@ -18063,9 +18024,9 @@ Handle Dictionary::New( return dict; } -template -Handle Dictionary::NewEmpty( - Isolate* isolate, PretenureFlag pretenure) { +template +Handle Dictionary::NewEmpty(Isolate* isolate, + PretenureFlag pretenure) { Handle dict = DerivedHashTable::New(isolate, 1, pretenure); // Attempt to add one element to the empty dictionary must cause reallocation. DCHECK(!dict->HasSufficientCapacityToAdd(1)); @@ -18074,8 +18035,8 @@ Handle Dictionary::NewEmpty( return dict; } -template -void Dictionary::SetRequiresCopyOnCapacityChange() { +template +void Dictionary::SetRequiresCopyOnCapacityChange() { DCHECK_EQ(0, DerivedHashTable::NumberOfElements()); DCHECK_EQ(0, DerivedHashTable::NumberOfDeletedElements()); // Make sure that HashTable::EnsureCapacity will create a copy. @@ -18083,9 +18044,8 @@ void Dictionary::SetRequiresCopyOnCapacityChange() { DCHECK(!DerivedHashTable::HasSufficientCapacityToAdd(1)); } - -template -Handle Dictionary::EnsureCapacity( +template +Handle Dictionary::EnsureCapacity( Handle dictionary, int n, Key key) { // Check whether there are enough enumeration indices to add n elements. if (Shape::kIsEnumerable && @@ -18117,9 +18077,8 @@ Handle Dictionary::EnsureCapacity( return DerivedHashTable::EnsureCapacity(dictionary, n, key); } - -template -Handle Dictionary::DeleteProperty( +template +Handle Dictionary::DeleteProperty( Handle dictionary, int entry) { Factory* factory = dictionary->GetIsolate()->factory(); PropertyDetails details = dictionary->DetailsAt(entry); @@ -18131,10 +18090,10 @@ Handle Dictionary::DeleteProperty( return factory->true_value(); } - -template -Handle Dictionary::AtPut( - Handle dictionary, Key key, Handle value) { +template +Handle Dictionary::AtPut(Handle dictionary, + Key key, + Handle value) { int entry = dictionary->FindEntry(key); // If the entry is present set the value; @@ -18154,12 +18113,11 @@ Handle Dictionary::AtPut( return dictionary; } -template -Handle Dictionary::Add(Handle dictionary, - Key key, - Handle value, - PropertyDetails details, - int* entry_out) { +template +Handle Dictionary::Add(Handle dictionary, + Key key, Handle value, + PropertyDetails details, + int* entry_out) { // Valdate key is absent. SLOW_DCHECK((dictionary->FindEntry(key) == Dictionary::kNotFound)); // Check whether the dictionary should be extended. @@ -18171,11 +18129,11 @@ Handle Dictionary::Add(Handle dictionary, } // Add a key, value pair to the dictionary. Returns entry value. -template -int Dictionary::AddEntry(Handle dictionary, - Key key, Handle value, - PropertyDetails details, - uint32_t hash) { +template +int Dictionary::AddEntry(Handle dictionary, Key key, + Handle value, + PropertyDetails details, + uint32_t hash) { // Compute the key object. Handle k = Shape::AsHandle(dictionary->GetIsolate(), key); @@ -18322,8 +18280,8 @@ Handle UnseededNumberDictionary::Set( return dictionary; } -template -int Dictionary::NumberOfEnumerableProperties() { +template +int Dictionary::NumberOfEnumerableProperties() { Isolate* isolate = this->GetIsolate(); int capacity = this->Capacity(); int result = 0; @@ -18351,11 +18309,10 @@ struct EnumIndexComparator { Dictionary* dict; }; -template -void Dictionary::CopyEnumKeysTo( - Handle> dictionary, - Handle storage, KeyCollectionMode mode, - KeyAccumulator* accumulator) { +template +void Dictionary::CopyEnumKeysTo( + Handle> dictionary, Handle storage, + KeyCollectionMode mode, KeyAccumulator* accumulator) { DCHECK_IMPLIES(mode != KeyCollectionMode::kOwnOnly, accumulator != nullptr); Isolate* isolate = dictionary->GetIsolate(); int length = storage->length(); @@ -18387,7 +18344,7 @@ void Dictionary::CopyEnumKeysTo( CHECK_EQ(length, properties); DisallowHeapAllocation no_gc; - Dictionary* raw_dictionary = *dictionary; + Dictionary* raw_dictionary = *dictionary; FixedArray* raw_storage = *storage; EnumIndexComparator cmp(static_cast(*dictionary)); Smi** start = reinterpret_cast(storage->GetFirstElementAddress()); @@ -18398,9 +18355,9 @@ void Dictionary::CopyEnumKeysTo( } } -template -Handle Dictionary::IterationIndices( - Handle> dictionary) { +template +Handle Dictionary::IterationIndices( + Handle> dictionary) { Isolate* isolate = dictionary->GetIsolate(); int capacity = dictionary->Capacity(); int length = dictionary->NumberOfElements(); @@ -18408,7 +18365,7 @@ Handle Dictionary::IterationIndices( int array_size = 0; { DisallowHeapAllocation no_gc; - Dictionary* raw_dict = *dictionary; + Dictionary* raw_dict = *dictionary; for (int i = 0; i < capacity; i++) { Object* k = raw_dict->KeyAt(i); if (!raw_dict->IsKey(isolate, k)) continue; @@ -18426,9 +18383,9 @@ Handle Dictionary::IterationIndices( return array; } -template -void Dictionary::CollectKeysTo( - Handle> dictionary, KeyAccumulator* keys) { +template +void Dictionary::CollectKeysTo( + Handle> dictionary, KeyAccumulator* keys) { Isolate* isolate = keys->isolate(); int capacity = dictionary->Capacity(); Handle array = @@ -18437,7 +18394,7 @@ void Dictionary::CollectKeysTo( PropertyFilter filter = keys->filter(); { DisallowHeapAllocation no_gc; - Dictionary* raw_dict = *dictionary; + Dictionary* raw_dict = *dictionary; for (int i = 0; i < capacity; i++) { Object* k = raw_dict->KeyAt(i); if (!raw_dict->IsKey(isolate, k) || k->FilterKey(filter)) continue; @@ -18486,8 +18443,8 @@ void Dictionary::CollectKeysTo( // Backwards lookup (slow). -template -Object* Dictionary::SlowReverseLookup(Object* value) { +template +Object* Dictionary::SlowReverseLookup(Object* value) { Isolate* isolate = this->GetIsolate(); int capacity = this->Capacity(); for (int i = 0; i < capacity; i++) { diff --git a/src/objects/code-cache.h b/src/objects/code-cache.h index 74f5362b61..b8bb615d97 100644 --- a/src/objects/code-cache.h +++ b/src/objects/code-cache.h @@ -36,8 +36,7 @@ class CodeCacheHashTableShape : public BaseShape { }; class CodeCacheHashTable - : public HashTable { + : public HashTable { public: static Handle Put(Handle table, Handle name, Handle code); diff --git a/src/objects/compilation-cache.h b/src/objects/compilation-cache.h index 55df1d7857..7c9b2fe39e 100644 --- a/src/objects/compilation-cache.h +++ b/src/objects/compilation-cache.h @@ -60,8 +60,7 @@ class InfoVectorPair { // recompilation stub, or to "old" code. This avoids memory leaks due to // premature caching of scripts and eval strings that are never needed later. class CompilationCacheTable - : public HashTable { + : public HashTable { public: // Find cached value for a string key, otherwise return null. Handle Lookup(Handle src, Handle context, diff --git a/src/objects/dictionary.h b/src/objects/dictionary.h index 966f112c6c..f77b207acd 100644 --- a/src/objects/dictionary.h +++ b/src/objects/dictionary.h @@ -21,11 +21,12 @@ class Handle; class Isolate; -template -class Dictionary : public HashTable { - typedef HashTable DerivedHashTable; +template +class Dictionary : public HashTable { + typedef HashTable DerivedHashTable; public: + typedef typename Shape::Key Key; // Returns the value at entry. Object* ValueAt(int entry) { return this->get(Derived::EntryToIndex(entry) + 1); @@ -66,15 +67,15 @@ class Dictionary : public HashTable { // Return the key indices sorted by its enumeration index. static Handle IterationIndices( - Handle> dictionary); + Handle> dictionary); // Collect the keys into the given KeyAccumulator, in ascending chronological // order of property creation. - static void CollectKeysTo(Handle> dictionary, + static void CollectKeysTo(Handle> dictionary, KeyAccumulator* keys); // Copies enumerable keys to preallocated fixed array. - static void CopyEnumKeysTo(Handle> dictionary, + static void CopyEnumKeysTo(Handle> dictionary, Handle storage, KeyCollectionMode mode, KeyAccumulator* accumulator); @@ -138,8 +139,8 @@ class Dictionary : public HashTable { }; template -class NameDictionaryBase : public Dictionary> { - typedef Dictionary> DerivedDictionary; +class NameDictionaryBase : public Dictionary { + typedef Dictionary DerivedDictionary; public: // Find entry for key, otherwise return kNotFound. Optimized version of @@ -270,14 +271,13 @@ class UnseededNumberDictionaryShape : public NumberDictionaryShape { }; extern template class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) - HashTable; + HashTable; extern template class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) - Dictionary; + Dictionary; class SeededNumberDictionary - : public Dictionary { + : public Dictionary { public: DECLARE_CAST(SeededNumberDictionary) @@ -333,8 +333,8 @@ class SeededNumberDictionary }; class UnseededNumberDictionary - : public Dictionary { + : public Dictionary { public: DECLARE_CAST(UnseededNumberDictionary) diff --git a/src/objects/hash-table.h b/src/objects/hash-table.h index 84c9314e93..946d662e9f 100644 --- a/src/objects/hash-table.h +++ b/src/objects/hash-table.h @@ -49,9 +49,10 @@ namespace internal { // beginning of the backing storage that can be used for non-element // information by subclasses. -template +template class BaseShape { public: + typedef KeyT Key; static const bool UsesSeed = false; static uint32_t Hash(Key key) { return 0; } static uint32_t SeededHash(Key key, uint32_t seed) { @@ -133,10 +134,11 @@ class V8_EXPORT_PRIVATE HashTableBase : public NON_EXPORTED_BASE(FixedArray) { } }; -template +template class HashTable : public HashTableBase { public: typedef Shape ShapeT; + typedef typename Shape::Key Key; // Wrapper methods inline uint32_t Hash(Key key) { @@ -279,9 +281,8 @@ class ObjectHashTableShape : public BaseShape> { // ObjectHashTable maps keys that are arbitrary objects to object values by // using the identity hash of the key for hashing purposes. class ObjectHashTable - : public HashTable> { - typedef HashTable> - DerivedHashTable; + : public HashTable { + typedef HashTable DerivedHashTable; public: DECLARE_CAST(ObjectHashTable) @@ -331,8 +332,7 @@ class ObjectHashSetShape : public ObjectHashTableShape { static const int kEntrySize = 1; }; -class ObjectHashSet - : public HashTable> { +class ObjectHashSet : public HashTable { public: static Handle Add(Handle set, Handle key); @@ -564,10 +564,8 @@ class WeakHashTableShape : public BaseShape> { // WeakHashTable maps keys that are arbitrary heap objects to heap object // values. The table wraps the keys in weak cells and store values directly. // Thus it references keys weakly and values strongly. -class WeakHashTable - : public HashTable, Handle> { - typedef HashTable, Handle> - DerivedHashTable; +class WeakHashTable : public HashTable> { + typedef HashTable> DerivedHashTable; public: DECLARE_CAST(WeakHashTable) diff --git a/src/objects/string-table.h b/src/objects/string-table.h index a827895e6a..2f9cc57057 100644 --- a/src/objects/string-table.h +++ b/src/objects/string-table.h @@ -37,8 +37,7 @@ class SeqOneByteString; // // No special elements in the prefix and the element size is 1 // because only the string itself (the key) needs to be stored. -class StringTable - : public HashTable { +class StringTable : public HashTable { public: // Find string in the string table. If it is not there yet, it is // added. The return value is the string found. @@ -81,7 +80,7 @@ class StringSetShape : public BaseShape { static const int kEntrySize = 1; }; -class StringSet : public HashTable { +class StringSet : public HashTable { public: static Handle New(Isolate* isolate); static Handle Add(Handle blacklist,