5#ifndef V8_OBJECTS_DICTIONARY_H_
6#define V8_OBJECTS_DICTIONARY_H_
22#ifdef V8_ENABLE_SWISS_NAME_DICTIONARY
23class SwissNameDictionary;
29template <
typename Derived,
typename Shape>
30class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) Dictionary
31 :
public HashTable<Derived, Shape> {
32 using DerivedHashTable = HashTable<Derived, Shape>;
35 using TodoShape = Shape;
36 using Key =
typename TodoShape::Key;
44 inline std::optional<Tagged<Object>> TryValueAt(
InternalIndex entry);
67 static const bool kIsOrderedDictionaryType =
false;
70 template <
template <
typename>
typename HandleType>
76 template <
template <
typename>
typename HandleType>
78 Isolate* isolate, HandleType<Derived> dictionary)
81 return DerivedHashTable::Shrink(isolate, dictionary);
84 int NumberOfEnumerableProperties();
98 template <
typename IsolateT,
template <
typename>
typename HandleType,
100 std::is_same<IsolateT, Isolate>::value ? AllocationType::kYoung
101 : AllocationType::kOld>
104 IsolateT* isolate, HandleType<Derived> dictionary, Key
key,
112 template <
typename IsolateT,
template <
typename>
typename HandleType,
114 std::is_same<IsolateT, Isolate>::value ? AllocationType::kYoung
115 : AllocationType::kOld>
117 static void UncheckedAdd(IsolateT* isolate, HandleType<Derived> dictionary,
127 template <
template <
typename>
typename HandleType>
130 Isolate* isolate, HandleType<Derived> dictionary, Key
key,
137#define EXTERN_DECLARE_DICTIONARY(DERIVED, SHAPE) \
138 EXTERN_DECLARE_HASH_TABLE(DERIVED, SHAPE) \
139 extern template class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) \
140 Dictionary<DERIVED, SHAPE>;
142template <
typename Key>
145 static const bool kHasDetails =
true;
146 template <
typename Dictionary>
150 template <
typename Dictionary>
153 static const bool kDoHashSpreading =
false;
154 static const uint32_t kHashBits = 0;
163 template <AllocationType allocation = AllocationType::kYoung>
166 template <AllocationType allocation = AllocationType::kOld>
169 static const int kEntryValueIndex = 1;
174 static const int kPrefixSize = 3;
175 static const int kEntrySize = 3;
176 static const bool kMatchNeedsHoleCheck =
false;
179template <
typename Derived,
typename Shape>
180class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) BaseNameDictionary
181 :
public Dictionary<Derived, Shape> {
182 using Key =
typename Shape::Key;
185 static const int kNextEnumerationIndexIndex =
186 HashTableBase::kPrefixStartIndex;
187 static const int kObjectHashIndex = kNextEnumerationIndexIndex + 1;
188 static const int kEntryValueIndex = 1;
190 inline void SetHash(
int hash);
191 inline int Hash()
const;
194 template <
typename IsolateT>
196 IsolateT* isolate,
int at_least_space_for,
202 static int NextEnumerationIndex(
Isolate* isolate,
205 inline int next_enumeration_index();
206 inline void set_next_enumeration_index(
int index);
212 template <
typename IsolateT,
template <
typename>
typename HandleType>
215 AddNoUpdateNextEnumerationIndex(IsolateT* isolate,
216 HandleType<Derived> dictionary, Key
key,
221 template <
template <
typename>
typename HandleType>
224 Isolate* isolate, HandleType<Derived> dictionary, Key
key,
230 using Dictionary<Derived, Shape>::FindInsertionEntry;
233#define EXTERN_DECLARE_BASE_NAME_DICTIONARY(DERIVED, SHAPE) \
234 EXTERN_DECLARE_DICTIONARY(DERIVED, SHAPE) \
235 extern template class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) \
236 BaseNameDictionary<DERIVED, SHAPE>;
247 static const
int kFlagsIndex = kObjectHashIndex + 1;
248 static const
int kEntryValueIndex = 1;
249 static const
int kEntryDetailsIndex = 2;
250 static const
int kInitialCapacity = 2;
255 inline
void set_hash(
int hash);
256 inline
int hash() const;
262 static constexpr
int kFlagsDefault = 0;
264 inline uint32_t flags() const;
265 inline
void set_flags(uint32_t flags);
268 template <typename IsolateT>
270 IsolateT* isolate,
int at_least_space_for,
281 static const bool kMatchNeedsHoleCheck =
true;
282 static const int kPrefixSize = 2;
283 static const int kEntrySize = 1;
285 template <
typename Dictionary>
289 template <
typename Dictionary>
318 std::optional<Tagged<PropertyCell>>
319 TryFindPropertyCellForConcurrentLookupIterator(
Isolate* isolate,
327 template <AllocationType allocation = AllocationType::kYoung>
329 template <AllocationType allocation = AllocationType::kOld>
337 static const bool kMatchNeedsHoleCheck =
true;
342 static const int kPrefixSize = 1;
343 static const int kEntrySize = 3;
348 static const bool kHasDetails =
false;
349 static const int kPrefixSize = 0;
350 static const int kEntrySize = 2;
352 template <
typename Dictionary>
358 template <
typename Dictionary>
378 static const int kEntryValueIndex = 1;
393 template <
template <
typename>
typename HandleType>
394 requires(std::is_convertible_v<HandleType<NumberDictionary>,
397 Isolate* isolate, HandleType<NumberDictionary> dictionary, uint32_t
key,
406 static void UncheckedSet(
Isolate* isolate,
410 static const int kMaxNumberKeyIndex = kPrefixStartIndex;
411 void UpdateMaxNumberKey(uint32_t
key,
422 inline bool requires_slow_elements();
423 inline void set_requires_slow_elements();
428 inline uint32_t max_number_key();
430 static const int kEntryValueIndex = 1;
431 static const int kEntryDetailsIndex = 2;
434 static const int kRequiresSlowElementsMask = 1;
435 static const int kRequiresSlowElementsTagSize = 1;
436 static const uint32_t kRequiresSlowElementsLimit = (1 << 29) - 1;
440 static const uint32_t kPreferFastElementsSizeFactor = 3;
446template <
typename Dictionary>
Tagged< PropertyCell > CellAt(InternalIndex entry)
static V8_WARN_UNUSED_RESULT HandleType< NumberDictionary > Set(Isolate *isolate, HandleType< NumberDictionary > dictionary, uint32_t key, DirectHandle< Object > value, DirectHandle< JSObject > dictionary_holder=DirectHandle< JSObject >::null(), PropertyDetails details=PropertyDetails::Empty())
int dictionary_index() const
static PropertyDetails DetailsAt(Tagged< Dictionary > dict, InternalIndex entry)
static void DetailsAtPut(Tagged< Dictionary > dict, InternalIndex entry, PropertyDetails value)
#define EXTERN_DECLARE_DICTIONARY(DERIVED, SHAPE)
#define EXTERN_DECLARE_BASE_NAME_DICTIONARY(DERIVED, SHAPE)
@ USE_DEFAULT_MINIMUM_CAPACITY
NameDictionary PropertyDictionary
#define DECL_BOOLEAN_ACCESSORS(name)
#define DECL_PRINTER(Name)
#define V8_EXPORT_PRIVATE
bool operator()(Tagged_t a, Tagged_t b)
EnumIndexComparator(Tagged< Dictionary > dict)
Tagged< Dictionary > dict
#define V8_WARN_UNUSED_RESULT
std::unique_ptr< ValueMirror > value
std::unique_ptr< ValueMirror > key