5#ifndef V8_OBJECTS_HASH_TABLE_INL_H_
6#define V8_OBJECTS_HASH_TABLE_INL_H_
26 DCHECK(IsEphemeronHashTable(
this));
29 objects()[
index].Relaxed_Store_no_write_barrier(value);
30#ifndef V8_DISABLE_WRITE_BARRIERS
40 DCHECK(IsEphemeronHashTable(
this));
43 objects()[
index].Relaxed_Store_no_write_barrier(value);
44#ifndef V8_DISABLE_WRITE_BARRIERS
45#if V8_ENABLE_UNCONDITIONAL_WRITE_BARRIERS
89 int raw_cap = at_least_space_for + (at_least_space_for >> 1);
108template <
typename Derived,
typename Shape>
110 return roots.hash_table_map();
115 return roots.name_to_index_hash_table_map();
120 return roots.registered_symbol_table_map();
125 return roots.ephemeron_hash_table_map();
128template <
typename Derived,
typename Shape>
129template <
typename IsolateT>
130InternalIndex HashTable<Derived, Shape>::FindEntry(IsolateT* isolate, Key
key) {
131 ReadOnlyRoots roots(isolate);
132 return FindEntry(isolate, roots,
key, TodoShape::Hash(roots,
key));
136template <
typename Derived,
typename Shape>
137InternalIndex HashTable<Derived, Shape>::FindEntry(PtrComprCageBase cage_base,
138 ReadOnlyRoots roots, Key
key,
141 uint32_t capacity = Capacity();
145 DCHECK_EQ(TodoShape::Hash(roots,
key),
static_cast<uint32_t
>(hash));
147 for (InternalIndex entry = FirstProbe(hash, capacity);;
148 entry = NextProbe(entry, count++, capacity)) {
153 if (TodoShape::kMatchNeedsHoleCheck && element == the_hole)
continue;
154 if (TodoShape::IsMatch(
key, element))
return entry;
158template <
typename Derived,
typename Shape>
159template <
typename IsolateT>
160InternalIndex HashTable<Derived, Shape>::FindInsertionEntry(IsolateT* isolate,
162 return FindInsertionEntry(isolate, ReadOnlyRoots(isolate), hash);
166template <
typename Derived,
typename Shape>
167bool HashTable<Derived, Shape>::IsKey(ReadOnlyRoots roots,
Tagged<Object> k) {
169 return k != roots.unchecked_undefined_value() &&
170 k != roots.unchecked_the_hole_value();
173template <
typename Derived,
typename Shape>
174bool HashTable<Derived, Shape>::ToKey(ReadOnlyRoots roots, InternalIndex entry,
177 if (!IsKey(roots, k))
return false;
178 *out_k = TodoShape::Unwrap(k);
182template <
typename Derived,
typename Shape>
183bool HashTable<Derived, Shape>::ToKey(PtrComprCageBase cage_base,
188 *out_k = TodoShape::Unwrap(k);
192template <
typename Derived,
typename Shape>
193Tagged<Object> HashTable<Derived, Shape>::KeyAt(InternalIndex entry) {
195 return KeyAt(cage_base, entry);
198template <
typename Derived,
typename Shape>
199Tagged<Object> HashTable<Derived, Shape>::KeyAt(PtrComprCageBase cage_base,
200 InternalIndex entry) {
201 return get(EntryToIndex(entry) + kEntryKeyIndex);
204template <
typename Derived,
typename Shape>
205Tagged<Object> HashTable<Derived, Shape>::KeyAt(InternalIndex entry,
206 RelaxedLoadTag tag) {
208 return KeyAt(cage_base, entry, tag);
211template <
typename Derived,
typename Shape>
212Tagged<Object> HashTable<Derived, Shape>::KeyAt(PtrComprCageBase cage_base,
214 RelaxedLoadTag tag) {
215 return get(EntryToIndex(entry) + kEntryKeyIndex, tag);
218template <
typename Derived,
typename Shape>
219void HashTable<Derived, Shape>::SetKeyAt(InternalIndex entry,
222 set_key(EntryToIndex(entry), value, mode);
225template <
typename Derived,
typename Shape>
226void HashTable<Derived, Shape>::set_key(
int index,
Tagged<Object> value) {
227 DCHECK(!IsEphemeronHashTable(
this));
231template <
typename Derived,
typename Shape>
232void HashTable<Derived, Shape>::set_key(
int index,
Tagged<Object> value,
234 DCHECK(!IsEphemeronHashTable(
this));
238template <
typename Derived,
typename Shape>
239void HashTable<Derived, Shape>::SetCapacity(
int capacity) {
255 if (!
IsSmi(hash))
return false;
273 return key->EnsureHash();
282 return *
key == other;
304template <
typename IsolateT>
312 table = EnsureCapacity(isolate, table);
317 raw_table->set(EntryToIndex(entry), *
key);
319 raw_table->ElementAdded();
#define SLOW_DCHECK(condition)
void SetNumberOfDeletedElements(int nod)
void ElementsRemoved(int n)
int NumberOfElements() const
static const int kMinCapacity
static const int kCapacityIndex
int NumberOfDeletedElements() const
void SetNumberOfElements(int nof)
InternalIndex::Range IterateEntries() const
void SetInitialNumberOfElements(int nof)
static const int kNumberOfDeletedElementsIndex
static int ComputeCapacity(int at_least_space_for)
static const int kNumberOfElementsIndex
static V8_INLINE bool IsOwnedByAnyHeap(Tagged< HeapObject > object)
static InternalIndex NotFound()
static int EntryToValueIndex(InternalIndex entry)
static Handle< NameToIndexHashTable > Add(IsolateT *isolate, Handle< NameToIndexHashTable > table, DirectHandle< Name > key, int32_t value)
static DirectHandle< Map > GetMap(RootsTable &roots)
static uint32_t Hash(ReadOnlyRoots roots, DirectHandle< Name > key)
static bool IsMatch(DirectHandle< Name > key, Tagged< Object > other)
static uint32_t HashForObject(ReadOnlyRoots roots, Tagged< Object > object)
bool Has(Isolate *isolate, DirectHandle< Object > key, int32_t hash)
static uint32_t Hash(ReadOnlyRoots roots, DirectHandle< Object > key)
static uint32_t HashForObject(ReadOnlyRoots roots, Tagged< Object > object)
static bool IsMatch(DirectHandle< Object > key, Tagged< Object > other)
static V8_EXPORT_PRIVATE bool SameValue(Tagged< Object > obj, Tagged< Object > other)
static uint32_t HashForObject(ReadOnlyRoots roots, Tagged< Object > object)
static bool IsMatch(DirectHandle< String > key, Tagged< Object > other)
static uint32_t Hash(ReadOnlyRoots roots, DirectHandle< String > key)
static DirectHandle< Map > GetMap(RootsTable &roots)
static constexpr int ToInt(const Tagged< Object > object)
static constexpr Tagged< Smi > FromInt(int value)
void set(int index, Tagged< ElementT > value, WriteBarrierMode mode=kDefaultMode)
static void ForEphemeronHashTable(Tagged< EphemeronHashTable > host, ObjectSlot slot, Tagged< Object > value, WriteBarrierMode mode)
V8_BASE_EXPORT constexpr uint32_t RoundUpToPowerOfTwo32(uint32_t value)
PerThreadAssertScopeDebugOnly< false, SAFEPOINTS_ASSERT, HEAP_ALLOCATION_ASSERT > DisallowGarbageCollection
SlotTraits::TObjectSlot ObjectSlot
ReadOnlyRoots GetReadOnlyRoots()
Tagged(T object) -> Tagged< T >
V8_INLINE constexpr bool IsSmi(TaggedImpl< kRefType, StorageType > obj)
V8_INLINE PtrComprCageBase GetPtrComprCageBase()
Tagged< To > Cast(Tagged< From > value, const v8::SourceLocation &loc=INIT_SOURCE_LOCATION_IN_DEBUG)
#define DCHECK_LE(v1, v2)
#define DCHECK_NE(v1, v2)
#define DCHECK_GE(v1, v2)
#define DCHECK(condition)
#define DCHECK_LT(v1, v2)
#define DCHECK_EQ(v1, v2)
#define DCHECK_GT(v1, v2)