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 {
FeedbackCell feedback_cell_;
};
EXTERN_DECLARE_HASH_TABLE(CompilationCacheTable, CompilationCacheShape)
// 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
// 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
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>
class BaseDictionaryShape : public BaseShape<Key> {
public:
......@@ -170,10 +175,12 @@ class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) BaseNameDictionary
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)
BaseNameDictionary<NameDictionary, NameDictionaryShape>;
EXTERN_DECLARE_BASE_NAME_DICTIONARY(NameDictionary, NameDictionaryShape)
class V8_EXPORT_PRIVATE NameDictionary
: public BaseNameDictionary<NameDictionary, NameDictionaryShape> {
......@@ -214,10 +221,7 @@ class V8_EXPORT_PRIVATE GlobalDictionaryShape : public NameDictionaryShape {
static inline RootIndex GetMapRootIndex();
};
class GlobalDictionary;
extern template class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE)
BaseNameDictionary<GlobalDictionary, GlobalDictionaryShape>;
EXTERN_DECLARE_BASE_NAME_DICTIONARY(GlobalDictionary, GlobalDictionaryShape)
class V8_EXPORT_PRIVATE GlobalDictionary
: public BaseNameDictionary<GlobalDictionary, GlobalDictionaryShape> {
......@@ -277,11 +281,7 @@ class SimpleNumberDictionaryShape : public NumberDictionaryBaseShape {
static inline RootIndex GetMapRootIndex();
};
extern template class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE)
HashTable<SimpleNumberDictionary, SimpleNumberDictionaryShape>;
extern template class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE)
Dictionary<SimpleNumberDictionary, SimpleNumberDictionaryShape>;
EXTERN_DECLARE_DICTIONARY(SimpleNumberDictionary, SimpleNumberDictionaryShape)
// SimpleNumberDictionary is used to map number to an entry.
class SimpleNumberDictionary
......@@ -300,11 +300,7 @@ class SimpleNumberDictionary
Dictionary<SimpleNumberDictionary, SimpleNumberDictionaryShape>);
};
extern template class EXPORT_TEMPLATE_DECLARE(
V8_EXPORT_PRIVATE) HashTable<NumberDictionary, NumberDictionaryShape>;
extern template class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE)
Dictionary<NumberDictionary, NumberDictionaryShape>;
EXTERN_DECLARE_DICTIONARY(NumberDictionary, NumberDictionaryShape)
// NumberDictionary is used as elements backing store and provides a bitfield
// and stores property details for every entry.
......
......@@ -243,6 +243,10 @@ class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) HashTable
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.
class HashTableKey {
public:
......@@ -321,12 +325,12 @@ class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) ObjectHashTableBase
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(
V8_EXPORT_PRIVATE) HashTable<ObjectHashTable, ObjectHashTableShape>;
extern template class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE)
ObjectHashTableBase<ObjectHashTable, ObjectHashTableShape>;
EXTERN_DECLARE_OBJECT_BASE_HASH_TABLE(ObjectHashTable, ObjectHashTableShape)
// ObjectHashTable maps keys that are arbitrary objects to object values by
// using the identity hash of the key for hashing purposes.
......@@ -346,12 +350,8 @@ class EphemeronHashTableShape : public ObjectHashTableShape {
static inline RootIndex GetMapRootIndex();
};
class EphemeronHashTable;
extern template class EXPORT_TEMPLATE_DECLARE(
V8_EXPORT_PRIVATE) HashTable<EphemeronHashTable, EphemeronHashTableShape>;
extern template class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE)
ObjectHashTableBase<EphemeronHashTable, EphemeronHashTableShape>;
EXTERN_DECLARE_OBJECT_BASE_HASH_TABLE(EphemeronHashTable,
EphemeronHashTableShape)
// EphemeronHashTable is similar to ObjectHashTable but gets special treatment
// by the GC. The GC treats its entries as ephemerons: both key and value are
......@@ -383,9 +383,7 @@ class ObjectHashSetShape : public ObjectHashTableShape {
static const int kEntrySize = 1;
};
class ObjectHashSet;
extern template class EXPORT_TEMPLATE_DECLARE(
V8_EXPORT_PRIVATE) HashTable<ObjectHashSet, ObjectHashSetShape>;
EXTERN_DECLARE_HASH_TABLE(ObjectHashSet, ObjectHashSetShape)
class V8_EXPORT_PRIVATE ObjectHashSet
: public HashTable<ObjectHashSet, ObjectHashSetShape> {
......
......@@ -6688,9 +6688,6 @@ Handle<Derived> HashTable<Derived, Shape>::EnsureCapacity(
return new_table;
}
template bool
HashTable<NameDictionary, NameDictionaryShape>::HasSufficientCapacityToAdd(int);
template <typename Derived, typename Shape>
bool HashTable<Derived, Shape>::HasSufficientCapacityToAdd(
int number_of_additional_elements) {
......@@ -8167,62 +8164,44 @@ Address Smi::LexicographicCompare(Isolate* isolate, Smi x, Smi y) {
// Please note this list is compiler dependent.
// Keep this at the end of this file
template class HashTable<StringTable, StringTableShape>;
template class EXPORT_TEMPLATE_DEFINE(
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>;
#define EXTERN_DEFINE_HASH_TABLE(DERIVED, SHAPE) \
template class EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE) \
HashTable<DERIVED, SHAPE>;
template class EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE)
Dictionary<GlobalDictionary, GlobalDictionaryShape>;
#define EXTERN_DEFINE_OBJECT_BASE_HASH_TABLE(DERIVED, SHAPE) \
EXTERN_DEFINE_HASH_TABLE(DERIVED, SHAPE) \
template class EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE) \
ObjectHashTableBase<DERIVED, SHAPE>;
template class EXPORT_TEMPLATE_DEFINE(
V8_EXPORT_PRIVATE) HashTable<NumberDictionary, NumberDictionaryShape>;
#define EXTERN_DEFINE_DICTIONARY(DERIVED, SHAPE) \
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)
Dictionary<NumberDictionary, NumberDictionaryShape>;
#define EXTERN_DEFINE_BASE_NAME_DICTIONARY(DERIVED, SHAPE) \
EXTERN_DEFINE_DICTIONARY(DERIVED, SHAPE) \
template class EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE) \
BaseNameDictionary<DERIVED, SHAPE>;
template class EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE)
HashTable<SimpleNumberDictionary, SimpleNumberDictionaryShape>;
EXTERN_DEFINE_HASH_TABLE(StringTable, StringTableShape)
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)
Dictionary<SimpleNumberDictionary, SimpleNumberDictionaryShape>;
EXTERN_DEFINE_OBJECT_BASE_HASH_TABLE(ObjectHashTable, ObjectHashTableShape)
EXTERN_DEFINE_OBJECT_BASE_HASH_TABLE(EphemeronHashTable,
EphemeronHashTableShape)
template Handle<NameDictionary>
HashTable<NameDictionary, NameDictionaryShape>::New(Isolate*, int,
AllocationType,
MinimumCapacity);
EXTERN_DEFINE_DICTIONARY(SimpleNumberDictionary, SimpleNumberDictionaryShape)
EXTERN_DEFINE_DICTIONARY(NumberDictionary, NumberDictionaryShape)
template V8_EXPORT_PRIVATE Handle<NameDictionary>
HashTable<NameDictionary, NameDictionaryShape>::Shrink(Isolate* isolate,
Handle<NameDictionary>,
int additionalCapacity);
EXTERN_DEFINE_BASE_NAME_DICTIONARY(NameDictionary, NameDictionaryShape)
EXTERN_DEFINE_BASE_NAME_DICTIONARY(GlobalDictionary, GlobalDictionaryShape)
template void HashTable<GlobalDictionary, GlobalDictionaryShape>::Rehash(
ReadOnlyRoots roots);
#undef EXTERN_DEFINE_HASH_TABLE
#undef EXTERN_DEFINE_OBJECT_BASE_HASH_TABLE
#undef EXTERN_DEFINE_DICTIONARY
#undef EXTERN_DEFINE_BASE_NAME_DICTIONARY
Maybe<bool> JSFinalizationRegistry::Cleanup(
Isolate* isolate, Handle<JSFinalizationRegistry> finalization_registry,
......
......@@ -55,6 +55,8 @@ class V8_EXPORT_PRIVATE StringTableShape : public BaseShape<StringTableKey*> {
class SeqOneByteString;
EXTERN_DECLARE_HASH_TABLE(StringTable, StringTableShape)
// StringTable.
//
// No special elements in the prefix and the element size is 1
......@@ -105,6 +107,8 @@ class StringSetShape : public BaseShape<String> {
static const int kEntrySize = 1;
};
EXTERN_DECLARE_HASH_TABLE(StringSet, StringSetShape)
class StringSet : public HashTable<StringSet, StringSetShape> {
public:
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