5#ifndef V8_UTILS_IDENTITY_MAP_H_
6#define V8_UTILS_IDENTITY_MAP_H_
19class StrongRootsEntry;
41 friend class IdentityMapTester;
52 strong_roots_entry_(nullptr),
54 is_iterable_(false) {}
58 RawEntry FindEntry(Address
key)
const;
59 RawEntry InsertEntry(Address
key);
60 bool DeleteEntry(Address
key, uintptr_t* deleted_value);
63 Address KeyAtIndex(
int index)
const;
65 RawEntry EntryAtIndex(
int index)
const;
66 int NextIndex(
int index)
const;
68 void EnableIteration();
69 void DisableIteration();
80 std::pair<int, bool> ScanKeysFor(Address address, uint32_t hash)
const;
81 std::pair<int, bool> InsertKey(Address address, uint32_t hash);
82 int Lookup(Address
key)
const;
83 std::pair<int, bool> LookupOrInsert(Address
key);
84 bool DeleteIndex(
int index, uintptr_t* deleted_value);
86 void Resize(
int new_capacity);
87 uint32_t Hash(Address address)
const;
88 bool ShouldGrow()
const;
115template <
typename V,
class AllocationPolicy>
118 static_assert(
sizeof(
V) <=
sizeof(uintptr_t));
119 static_assert(std::is_trivially_copyable<V>::value);
120 static_assert(std::is_trivially_destructible<V>::value);
138 return {
reinterpret_cast<V*
>(raw.entry), raw.already_exists};
163 if (deleted_value !=
nullptr && deleted_something) {
164 *deleted_value = *
reinterpret_cast<V*
>(&v);
166 return deleted_something;
191 return index_ != other.index_;
194 return index_ == other.index_;
210 map_->EnableIteration();
216 map_->DisableIteration();
235 allocator_.template AllocateArray<uintptr_t, Buffer>(length);
236 std::uninitialized_fill_n(
result, length, value);
bool DeleteEntry(Address key, uintptr_t *deleted_value)
virtual void DeletePointerArray(uintptr_t *array, size_t length)=0
IdentityMapBase & operator=(const IdentityMapBase &)=delete
virtual uintptr_t * NewPointerArray(size_t length, uintptr_t value)=0
RawEntry FindEntry(Address key) const
IdentityMapBase(const IdentityMapBase &)=delete
IdentityMapFindResult< uintptr_t > FindOrInsertEntry(Address key)
int NextIndex(int index) const
Address KeyAtIndex(int index) const
RawEntry EntryAtIndex(int index) const
IdentityMapBase(Heap *heap)
base::hash< uintptr_t > hasher_
StrongRootsEntry * strong_roots_entry_
RawEntry InsertEntry(Address key)
IteratableScope & operator=(const IteratableScope &)=delete
IteratableScope(const IteratableScope &)=delete
IteratableScope(IdentityMap *map)
bool operator==(const Iterator &other) const
bool operator!=(const Iterator &other) const
Iterator(IdentityMap *map, int index)
Tagged< Object > key() const
IdentityMap(const IdentityMap &)=delete
bool Delete(Tagged< Object > key, V *deleted_value)
void Insert(DirectHandle< Object > key, V v)
uintptr_t * NewPointerArray(size_t length, uintptr_t value) override
bool Delete(DirectHandle< Object > key, V *deleted_value)
V * Find(DirectHandle< Object > key) const
IdentityMap(Heap *heap, AllocationPolicy allocator=AllocationPolicy())
void DeletePointerArray(uintptr_t *array, size_t length) override
V * Find(Tagged< Object > key) const
AllocationPolicy allocator_
IdentityMapFindResult< V > FindOrInsert(Tagged< Object > key)
IdentityMap & operator=(const IdentityMap &)=delete
void Insert(Tagged< Object > key, V v)
IdentityMapFindResult< V > FindOrInsert(DirectHandle< Object > key)
ZoneVector< RpoNumber > & result
void DeleteArray(T *array)
#define V8_EXPORT_PRIVATE
std::unique_ptr< ValueMirror > key