diff options
Diffstat (limited to 'deps/v8/src/objects/hash-table.h')
-rw-r--r-- | deps/v8/src/objects/hash-table.h | 64 |
1 files changed, 43 insertions, 21 deletions
diff --git a/deps/v8/src/objects/hash-table.h b/deps/v8/src/objects/hash-table.h index 66d3f6dfb2..5bb529a121 100644 --- a/deps/v8/src/objects/hash-table.h +++ b/deps/v8/src/objects/hash-table.h @@ -8,6 +8,8 @@ #include "src/base/compiler-specific.h" #include "src/globals.h" #include "src/objects/fixed-array.h" +#include "src/objects/smi.h" +#include "src/roots.h" // Has to be the last include (doesn't have include guards): #include "src/objects/object-macros.h" @@ -31,11 +33,11 @@ namespace internal { // class ExampleShape { // public: // // Tells whether key matches other. -// static bool IsMatch(Key key, Object* other); +// static bool IsMatch(Key key, Object other); // // Returns the hash value for key. // static uint32_t Hash(Isolate* isolate, Key key); // // Returns the hash value for object. -// static uint32_t HashForObject(Isolate* isolate, Object* object); +// static uint32_t HashForObject(Isolate* isolate, Object object); // // Convert key to an object. // static inline Handle<Object> AsHandle(Isolate* isolate, Key key); // // The prefix size indicates number of elements in the beginning @@ -57,9 +59,9 @@ class BaseShape { typedef KeyT Key; static inline RootIndex GetMapRootIndex(); static const bool kNeedsHoleCheck = true; - static Object* Unwrap(Object* key) { return key; } - static inline bool IsKey(ReadOnlyRoots roots, Object* key); - static inline bool IsLive(ReadOnlyRoots roots, Object* key); + static Object Unwrap(Object key) { return key; } + static inline bool IsKey(ReadOnlyRoots roots, Object key); + static inline bool IsLive(ReadOnlyRoots roots, Object key); }; class V8_EXPORT_PRIVATE HashTableBase : public NON_EXPORTED_BASE(FixedArray) { @@ -123,6 +125,8 @@ class V8_EXPORT_PRIVATE HashTableBase : public NON_EXPORTED_BASE(FixedArray) { uint32_t size) { return (last + number) & (size - 1); } + + OBJECT_CONSTRUCTORS(HashTableBase, FixedArray) }; template <typename Derived, typename Shape> @@ -137,8 +141,6 @@ class HashTable : public HashTableBase { PretenureFlag pretenure = NOT_TENURED, MinimumCapacity capacity_option = USE_DEFAULT_MINIMUM_CAPACITY); - DECL_CAST(HashTable) - // Garbage collection support. void IteratePrefix(ObjectVisitor* visitor); void IterateElements(ObjectVisitor* visitor); @@ -152,19 +154,19 @@ class HashTable : public HashTableBase { // Tells whether k is a real key. The hole and undefined are not allowed // as keys and can be used to indicate missing or deleted elements. - static bool IsKey(ReadOnlyRoots roots, Object* k); + static bool IsKey(ReadOnlyRoots roots, Object k); - inline bool ToKey(ReadOnlyRoots roots, int entry, Object** out_k); + inline bool ToKey(ReadOnlyRoots roots, int entry, Object* out_k); // Returns the key at entry. - Object* KeyAt(int entry) { return get(EntryToIndex(entry) + kEntryKeyIndex); } + Object KeyAt(int entry) { return get(EntryToIndex(entry) + kEntryKeyIndex); } static const int kElementsStartIndex = kPrefixStartIndex + Shape::kPrefixSize; static const int kEntrySize = Shape::kEntrySize; STATIC_ASSERT(kEntrySize > 0); static const int kEntryKeyIndex = 0; static const int kElementsStartOffset = - kHeaderSize + kElementsStartIndex * kPointerSize; + kHeaderSize + kElementsStartIndex * kTaggedSize; // Maximal capacity of HashTable. Based on maximal length of underlying // FixedArray. Staying below kMaxCapacity also ensures that EntryToIndex // cannot overflow. @@ -175,7 +177,12 @@ class HashTable : public HashTableBase { static const int kMinShrinkCapacity = 16; // Maximum length to create a regular HashTable (aka. non large object). +#if V8_HOST_ARCH_PPC + // Reduced kMaxRegularCapacity due to reduced kMaxRegularHeapObjectSize + static const int kMaxRegularCapacity = 16384 / 2; +#else static const int kMaxRegularCapacity = 16384; +#endif // Returns the index for an entry (of the key) static constexpr inline int EntryToIndex(int entry) { @@ -226,13 +233,15 @@ class HashTable : public HashTableBase { // Returns _expected_ if one of entries given by the first _probe_ probes is // equal to _expected_. Otherwise, returns the entry given by the probe // number _probe_. - uint32_t EntryForProbe(Isolate* isolate, Object* k, int probe, + uint32_t EntryForProbe(Isolate* isolate, Object k, int probe, uint32_t expected); void Swap(uint32_t entry1, uint32_t entry2, WriteBarrierMode mode); // Rehashes this hash-table into the new table. - void Rehash(Isolate* isolate, Derived* new_table); + void Rehash(Isolate* isolate, Derived new_table); + + OBJECT_CONSTRUCTORS(HashTable, HashTableBase) }; // HashTableKey is an abstract superclass for virtual key behavior. @@ -241,7 +250,7 @@ class HashTableKey { explicit HashTableKey(uint32_t hash) : hash_(hash) {} // Returns whether the other object matches this key. - virtual bool IsMatch(Object* other) = 0; + virtual bool IsMatch(Object other) = 0; // Returns the hash value for this key. // Required. virtual ~HashTableKey() = default; @@ -260,9 +269,9 @@ class HashTableKey { class ObjectHashTableShape : public BaseShape<Handle<Object>> { public: - static inline bool IsMatch(Handle<Object> key, Object* other); + static inline bool IsMatch(Handle<Object> key, Object other); static inline uint32_t Hash(Isolate* isolate, Handle<Object> key); - static inline uint32_t HashForObject(Isolate* isolate, Object* object); + static inline uint32_t HashForObject(Isolate* isolate, Object object); static inline Handle<Object> AsHandle(Handle<Object> key); static const int kPrefixSize = 0; static const int kEntryValueIndex = 1; @@ -275,12 +284,12 @@ class ObjectHashTableBase : public HashTable<Derived, Shape> { public: // Looks up the value associated with the given key. The hole value is // returned in case the key is not present. - Object* Lookup(Handle<Object> key); - Object* Lookup(Handle<Object> key, int32_t hash); - Object* Lookup(ReadOnlyRoots roots, Handle<Object> key, int32_t hash); + Object Lookup(Handle<Object> key); + Object Lookup(Handle<Object> key, int32_t hash); + Object Lookup(ReadOnlyRoots roots, Handle<Object> key, int32_t hash); // Returns the value at entry. - Object* ValueAt(int entry); + Object ValueAt(int entry); // Overwrite all keys and values with the hole value. static void FillEntriesWithHoles(Handle<Derived>); @@ -306,8 +315,10 @@ class ObjectHashTableBase : public HashTable<Derived, Shape> { } protected: - void AddEntry(int entry, Object* key, Object* value); + void AddEntry(int entry, Object key, Object value); void RemoveEntry(int entry); + + OBJECT_CONSTRUCTORS(ObjectHashTableBase, HashTable<Derived, Shape>) }; // ObjectHashTable maps keys that are arbitrary objects to object values by @@ -317,6 +328,10 @@ class ObjectHashTable public: DECL_CAST(ObjectHashTable) DECL_PRINTER(ObjectHashTable) + + OBJECT_CONSTRUCTORS( + ObjectHashTable, + ObjectHashTableBase<ObjectHashTable, ObjectHashTableShape>) }; class EphemeronHashTableShape : public ObjectHashTableShape { @@ -336,6 +351,10 @@ class EphemeronHashTable protected: friend class MarkCompactCollector; + + OBJECT_CONSTRUCTORS( + EphemeronHashTable, + ObjectHashTableBase<EphemeronHashTable, EphemeronHashTableShape>) }; class ObjectHashSetShape : public ObjectHashTableShape { @@ -353,6 +372,9 @@ class ObjectHashSet : public HashTable<ObjectHashSet, ObjectHashSetShape> { inline bool Has(Isolate* isolate, Handle<Object> key); DECL_CAST(ObjectHashSet) + + OBJECT_CONSTRUCTORS(ObjectHashSet, + HashTable<ObjectHashSet, ObjectHashSetShape>) }; } // namespace internal |