Commit e91ccc43 authored by Leszek Swirski's avatar Leszek Swirski Committed by Commit Bot

[cleanup] Unify HashTable specialisation instantiation

Use macros to unify how HashTable (and subclasses) are marked as
externally specialised, and how those specialisations are initialised.

This cleanup will make it easier in the future to also add
specialisations of HashTable methods for Isolate/OffThreadIsolate.

Bug: chromium:1011762
Change-Id: Ibb62cf30d3ba40170e1d35ab72ada0f74963a5c4
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2083023
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Auto-Submit: Leszek Swirski <leszeks@chromium.org>
Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#66528}
parent bc714409
...@@ -70,6 +70,8 @@ class InfoCellPair { ...@@ -70,6 +70,8 @@ class InfoCellPair {
FeedbackCell feedback_cell_; FeedbackCell feedback_cell_;
}; };
EXTERN_DECLARE_HASH_TABLE(CompilationCacheTable, CompilationCacheShape)
// This cache is used in two different variants. For regexp caching, it simply // This cache is used in two different variants. For regexp caching, it simply
// maps identifying info of the regexp to the cached regexp object. Scripts and // maps identifying info of the regexp to the cached regexp object. Scripts and
// eval code only gets cached after a second probe for the code object. To do // eval code only gets cached after a second probe for the code object. To do
......
...@@ -89,6 +89,11 @@ class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) Dictionary ...@@ -89,6 +89,11 @@ class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) Dictionary
OBJECT_CONSTRUCTORS(Dictionary, HashTable<Derived, Shape>); OBJECT_CONSTRUCTORS(Dictionary, HashTable<Derived, Shape>);
}; };
#define EXTERN_DECLARE_DICTIONARY(DERIVED, SHAPE) \
EXTERN_DECLARE_HASH_TABLE(DERIVED, SHAPE) \
extern template class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) \
Dictionary<DERIVED, SHAPE>;
template <typename Key> template <typename Key>
class BaseDictionaryShape : public BaseShape<Key> { class BaseDictionaryShape : public BaseShape<Key> {
public: public:
...@@ -170,10 +175,12 @@ class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) BaseNameDictionary ...@@ -170,10 +175,12 @@ class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) BaseNameDictionary
OBJECT_CONSTRUCTORS(BaseNameDictionary, Dictionary<Derived, Shape>); OBJECT_CONSTRUCTORS(BaseNameDictionary, Dictionary<Derived, Shape>);
}; };
class NameDictionary; #define EXTERN_DECLARE_BASE_NAME_DICTIONARY(DERIVED, SHAPE) \
EXTERN_DECLARE_DICTIONARY(DERIVED, SHAPE) \
extern template class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) \
BaseNameDictionary<DERIVED, SHAPE>;
extern template class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) EXTERN_DECLARE_BASE_NAME_DICTIONARY(NameDictionary, NameDictionaryShape)
BaseNameDictionary<NameDictionary, NameDictionaryShape>;
class V8_EXPORT_PRIVATE NameDictionary class V8_EXPORT_PRIVATE NameDictionary
: public BaseNameDictionary<NameDictionary, NameDictionaryShape> { : public BaseNameDictionary<NameDictionary, NameDictionaryShape> {
...@@ -214,10 +221,7 @@ class V8_EXPORT_PRIVATE GlobalDictionaryShape : public NameDictionaryShape { ...@@ -214,10 +221,7 @@ class V8_EXPORT_PRIVATE GlobalDictionaryShape : public NameDictionaryShape {
static inline RootIndex GetMapRootIndex(); static inline RootIndex GetMapRootIndex();
}; };
class GlobalDictionary; EXTERN_DECLARE_BASE_NAME_DICTIONARY(GlobalDictionary, GlobalDictionaryShape)
extern template class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE)
BaseNameDictionary<GlobalDictionary, GlobalDictionaryShape>;
class V8_EXPORT_PRIVATE GlobalDictionary class V8_EXPORT_PRIVATE GlobalDictionary
: public BaseNameDictionary<GlobalDictionary, GlobalDictionaryShape> { : public BaseNameDictionary<GlobalDictionary, GlobalDictionaryShape> {
...@@ -277,11 +281,7 @@ class SimpleNumberDictionaryShape : public NumberDictionaryBaseShape { ...@@ -277,11 +281,7 @@ class SimpleNumberDictionaryShape : public NumberDictionaryBaseShape {
static inline RootIndex GetMapRootIndex(); static inline RootIndex GetMapRootIndex();
}; };
extern template class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) EXTERN_DECLARE_DICTIONARY(SimpleNumberDictionary, SimpleNumberDictionaryShape)
HashTable<SimpleNumberDictionary, SimpleNumberDictionaryShape>;
extern template class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE)
Dictionary<SimpleNumberDictionary, SimpleNumberDictionaryShape>;
// SimpleNumberDictionary is used to map number to an entry. // SimpleNumberDictionary is used to map number to an entry.
class SimpleNumberDictionary class SimpleNumberDictionary
...@@ -300,11 +300,7 @@ class SimpleNumberDictionary ...@@ -300,11 +300,7 @@ class SimpleNumberDictionary
Dictionary<SimpleNumberDictionary, SimpleNumberDictionaryShape>); Dictionary<SimpleNumberDictionary, SimpleNumberDictionaryShape>);
}; };
extern template class EXPORT_TEMPLATE_DECLARE( EXTERN_DECLARE_DICTIONARY(NumberDictionary, NumberDictionaryShape)
V8_EXPORT_PRIVATE) HashTable<NumberDictionary, NumberDictionaryShape>;
extern template class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE)
Dictionary<NumberDictionary, NumberDictionaryShape>;
// NumberDictionary is used as elements backing store and provides a bitfield // NumberDictionary is used as elements backing store and provides a bitfield
// and stores property details for every entry. // and stores property details for every entry.
......
...@@ -243,6 +243,10 @@ class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) HashTable ...@@ -243,6 +243,10 @@ class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) HashTable
OBJECT_CONSTRUCTORS(HashTable, HashTableBase); OBJECT_CONSTRUCTORS(HashTable, HashTableBase);
}; };
#define EXTERN_DECLARE_HASH_TABLE(DERIVED, SHAPE) \
extern template class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) \
HashTable<class DERIVED, SHAPE>;
// HashTableKey is an abstract superclass for virtual key behavior. // HashTableKey is an abstract superclass for virtual key behavior.
class HashTableKey { class HashTableKey {
public: public:
...@@ -321,12 +325,12 @@ class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) ObjectHashTableBase ...@@ -321,12 +325,12 @@ class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) ObjectHashTableBase
OBJECT_CONSTRUCTORS(ObjectHashTableBase, HashTable<Derived, Shape>); OBJECT_CONSTRUCTORS(ObjectHashTableBase, HashTable<Derived, Shape>);
}; };
class ObjectHashTable; #define EXTERN_DECLARE_OBJECT_BASE_HASH_TABLE(DERIVED, SHAPE) \
EXTERN_DECLARE_HASH_TABLE(DERIVED, SHAPE) \
extern template class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) \
ObjectHashTableBase<class DERIVED, SHAPE>;
extern template class EXPORT_TEMPLATE_DECLARE( EXTERN_DECLARE_OBJECT_BASE_HASH_TABLE(ObjectHashTable, ObjectHashTableShape)
V8_EXPORT_PRIVATE) HashTable<ObjectHashTable, ObjectHashTableShape>;
extern template class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE)
ObjectHashTableBase<ObjectHashTable, ObjectHashTableShape>;
// ObjectHashTable maps keys that are arbitrary objects to object values by // ObjectHashTable maps keys that are arbitrary objects to object values by
// using the identity hash of the key for hashing purposes. // using the identity hash of the key for hashing purposes.
...@@ -346,12 +350,8 @@ class EphemeronHashTableShape : public ObjectHashTableShape { ...@@ -346,12 +350,8 @@ class EphemeronHashTableShape : public ObjectHashTableShape {
static inline RootIndex GetMapRootIndex(); static inline RootIndex GetMapRootIndex();
}; };
class EphemeronHashTable; EXTERN_DECLARE_OBJECT_BASE_HASH_TABLE(EphemeronHashTable,
EphemeronHashTableShape)
extern template class EXPORT_TEMPLATE_DECLARE(
V8_EXPORT_PRIVATE) HashTable<EphemeronHashTable, EphemeronHashTableShape>;
extern template class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE)
ObjectHashTableBase<EphemeronHashTable, EphemeronHashTableShape>;
// EphemeronHashTable is similar to ObjectHashTable but gets special treatment // EphemeronHashTable is similar to ObjectHashTable but gets special treatment
// by the GC. The GC treats its entries as ephemerons: both key and value are // by the GC. The GC treats its entries as ephemerons: both key and value are
...@@ -383,9 +383,7 @@ class ObjectHashSetShape : public ObjectHashTableShape { ...@@ -383,9 +383,7 @@ class ObjectHashSetShape : public ObjectHashTableShape {
static const int kEntrySize = 1; static const int kEntrySize = 1;
}; };
class ObjectHashSet; EXTERN_DECLARE_HASH_TABLE(ObjectHashSet, ObjectHashSetShape)
extern template class EXPORT_TEMPLATE_DECLARE(
V8_EXPORT_PRIVATE) HashTable<ObjectHashSet, ObjectHashSetShape>;
class V8_EXPORT_PRIVATE ObjectHashSet class V8_EXPORT_PRIVATE ObjectHashSet
: public HashTable<ObjectHashSet, ObjectHashSetShape> { : public HashTable<ObjectHashSet, ObjectHashSetShape> {
......
...@@ -6688,9 +6688,6 @@ Handle<Derived> HashTable<Derived, Shape>::EnsureCapacity( ...@@ -6688,9 +6688,6 @@ Handle<Derived> HashTable<Derived, Shape>::EnsureCapacity(
return new_table; return new_table;
} }
template bool
HashTable<NameDictionary, NameDictionaryShape>::HasSufficientCapacityToAdd(int);
template <typename Derived, typename Shape> template <typename Derived, typename Shape>
bool HashTable<Derived, Shape>::HasSufficientCapacityToAdd( bool HashTable<Derived, Shape>::HasSufficientCapacityToAdd(
int number_of_additional_elements) { int number_of_additional_elements) {
...@@ -8167,62 +8164,44 @@ Address Smi::LexicographicCompare(Isolate* isolate, Smi x, Smi y) { ...@@ -8167,62 +8164,44 @@ Address Smi::LexicographicCompare(Isolate* isolate, Smi x, Smi y) {
// Please note this list is compiler dependent. // Please note this list is compiler dependent.
// Keep this at the end of this file // Keep this at the end of this file
template class HashTable<StringTable, StringTableShape>; #define EXTERN_DEFINE_HASH_TABLE(DERIVED, SHAPE) \
template class EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE) \
template class EXPORT_TEMPLATE_DEFINE( HashTable<DERIVED, SHAPE>;
V8_EXPORT_PRIVATE) HashTable<CompilationCacheTable, CompilationCacheShape>;
template class EXPORT_TEMPLATE_DEFINE(
V8_EXPORT_PRIVATE) HashTable<ObjectHashTable, ObjectHashTableShape>;
template class EXPORT_TEMPLATE_DEFINE(
V8_EXPORT_PRIVATE) HashTable<ObjectHashSet, ObjectHashSetShape>;
template class EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE)
ObjectHashTableBase<ObjectHashTable, ObjectHashTableShape>;
template class EXPORT_TEMPLATE_DEFINE(
V8_EXPORT_PRIVATE) HashTable<EphemeronHashTable, EphemeronHashTableShape>;
template class EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE)
ObjectHashTableBase<EphemeronHashTable, EphemeronHashTableShape>;
template class EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE)
BaseNameDictionary<NameDictionary, NameDictionaryShape>;
template class EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE)
BaseNameDictionary<GlobalDictionary, GlobalDictionaryShape>;
template class EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE)
Dictionary<NameDictionary, NameDictionaryShape>;
template class EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE) #define EXTERN_DEFINE_OBJECT_BASE_HASH_TABLE(DERIVED, SHAPE) \
Dictionary<GlobalDictionary, GlobalDictionaryShape>; EXTERN_DEFINE_HASH_TABLE(DERIVED, SHAPE) \
template class EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE) \
ObjectHashTableBase<DERIVED, SHAPE>;
template class EXPORT_TEMPLATE_DEFINE( #define EXTERN_DEFINE_DICTIONARY(DERIVED, SHAPE) \
V8_EXPORT_PRIVATE) HashTable<NumberDictionary, NumberDictionaryShape>; EXTERN_DEFINE_HASH_TABLE(DERIVED, SHAPE) \
template class EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE) \
Dictionary<DERIVED, SHAPE>;
template class EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE) #define EXTERN_DEFINE_BASE_NAME_DICTIONARY(DERIVED, SHAPE) \
Dictionary<NumberDictionary, NumberDictionaryShape>; EXTERN_DEFINE_DICTIONARY(DERIVED, SHAPE) \
template class EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE) \
BaseNameDictionary<DERIVED, SHAPE>;
template class EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE) EXTERN_DEFINE_HASH_TABLE(StringTable, StringTableShape)
HashTable<SimpleNumberDictionary, SimpleNumberDictionaryShape>; EXTERN_DEFINE_HASH_TABLE(StringSet, StringSetShape)
EXTERN_DEFINE_HASH_TABLE(CompilationCacheTable, CompilationCacheShape)
EXTERN_DEFINE_HASH_TABLE(ObjectHashSet, ObjectHashSetShape)
template class EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE) EXTERN_DEFINE_OBJECT_BASE_HASH_TABLE(ObjectHashTable, ObjectHashTableShape)
Dictionary<SimpleNumberDictionary, SimpleNumberDictionaryShape>; EXTERN_DEFINE_OBJECT_BASE_HASH_TABLE(EphemeronHashTable,
EphemeronHashTableShape)
template Handle<NameDictionary> EXTERN_DEFINE_DICTIONARY(SimpleNumberDictionary, SimpleNumberDictionaryShape)
HashTable<NameDictionary, NameDictionaryShape>::New(Isolate*, int, EXTERN_DEFINE_DICTIONARY(NumberDictionary, NumberDictionaryShape)
AllocationType,
MinimumCapacity);
template V8_EXPORT_PRIVATE Handle<NameDictionary> EXTERN_DEFINE_BASE_NAME_DICTIONARY(NameDictionary, NameDictionaryShape)
HashTable<NameDictionary, NameDictionaryShape>::Shrink(Isolate* isolate, EXTERN_DEFINE_BASE_NAME_DICTIONARY(GlobalDictionary, GlobalDictionaryShape)
Handle<NameDictionary>,
int additionalCapacity);
template void HashTable<GlobalDictionary, GlobalDictionaryShape>::Rehash( #undef EXTERN_DEFINE_HASH_TABLE
ReadOnlyRoots roots); #undef EXTERN_DEFINE_OBJECT_BASE_HASH_TABLE
#undef EXTERN_DEFINE_DICTIONARY
#undef EXTERN_DEFINE_BASE_NAME_DICTIONARY
Maybe<bool> JSFinalizationRegistry::Cleanup( Maybe<bool> JSFinalizationRegistry::Cleanup(
Isolate* isolate, Handle<JSFinalizationRegistry> finalization_registry, Isolate* isolate, Handle<JSFinalizationRegistry> finalization_registry,
......
...@@ -55,6 +55,8 @@ class V8_EXPORT_PRIVATE StringTableShape : public BaseShape<StringTableKey*> { ...@@ -55,6 +55,8 @@ class V8_EXPORT_PRIVATE StringTableShape : public BaseShape<StringTableKey*> {
class SeqOneByteString; class SeqOneByteString;
EXTERN_DECLARE_HASH_TABLE(StringTable, StringTableShape)
// StringTable. // StringTable.
// //
// No special elements in the prefix and the element size is 1 // No special elements in the prefix and the element size is 1
...@@ -105,6 +107,8 @@ class StringSetShape : public BaseShape<String> { ...@@ -105,6 +107,8 @@ class StringSetShape : public BaseShape<String> {
static const int kEntrySize = 1; static const int kEntrySize = 1;
}; };
EXTERN_DECLARE_HASH_TABLE(StringSet, StringSetShape)
class StringSet : public HashTable<StringSet, StringSetShape> { class StringSet : public HashTable<StringSet, StringSetShape> {
public: public:
V8_EXPORT_PRIVATE static Handle<StringSet> New(Isolate* isolate); V8_EXPORT_PRIVATE static Handle<StringSet> New(Isolate* isolate);
......
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