5#ifndef V8_OBJECTS_DICTIONARY_INL_H_
6#define V8_OBJECTS_DICTIONARY_INL_H_
25template <
typename Derived,
typename Shape>
26Tagged<Object> Dictionary<Derived, Shape>::ValueAt(InternalIndex entry) {
28 return ValueAt(cage_base, entry);
31template <
typename Derived,
typename Shape>
32Tagged<Object> Dictionary<Derived, Shape>::ValueAt(PtrComprCageBase cage_base,
33 InternalIndex entry) {
34 return this->get(DerivedHashTable::EntryToIndex(entry) +
35 Derived::kEntryValueIndex);
38template <
typename Derived,
typename Shape>
39Tagged<Object> Dictionary<Derived, Shape>::ValueAt(InternalIndex entry,
40 SeqCstAccessTag tag) {
42 return ValueAt(cage_base, entry, tag);
45template <
typename Derived,
typename Shape>
46Tagged<Object> Dictionary<Derived, Shape>::ValueAt(PtrComprCageBase cage_base,
48 SeqCstAccessTag tag) {
50 DerivedHashTable::EntryToIndex(entry) + Derived::kEntryValueIndex, tag);
53template <
typename Derived,
typename Shape>
54std::optional<Tagged<Object>> Dictionary<Derived, Shape>::TryValueAt(
55 InternalIndex entry) {
64 if (DerivedHashTable::EntryToIndex(entry) + Derived::kEntryValueIndex >=
68 return ValueAt(entry);
71template <
typename Derived,
typename Shape>
72void Dictionary<Derived, Shape>::ValueAtPut(InternalIndex entry,
74 this->set(DerivedHashTable::EntryToIndex(entry) + Derived::kEntryValueIndex,
78template <
typename Derived,
typename Shape>
79void Dictionary<Derived, Shape>::ValueAtPut(InternalIndex entry,
81 SeqCstAccessTag tag) {
82 this->set(DerivedHashTable::EntryToIndex(entry) + Derived::kEntryValueIndex,
86template <
typename Derived,
typename Shape>
87Tagged<Object> Dictionary<Derived, Shape>::ValueAtSwap(InternalIndex entry,
89 SeqCstAccessTag tag) {
91 DerivedHashTable::EntryToIndex(entry) + Derived::kEntryValueIndex, value,
95template <
typename Derived,
typename Shape>
98 SeqCstAccessTag tag) {
99 return this->compare_and_swap(
100 DerivedHashTable::EntryToIndex(entry) + Derived::kEntryValueIndex,
101 expected, value, tag);
104template <
typename Derived,
typename Shape>
105PropertyDetails Dictionary<Derived, Shape>::DetailsAt(InternalIndex entry) {
109template <
typename Derived,
typename Shape>
110void Dictionary<Derived, Shape>::DetailsAtPut(InternalIndex entry,
111 PropertyDetails value) {
115template <
typename Derived,
typename Shape>
116void BaseNameDictionary<Derived, Shape>::set_next_enumeration_index(
int index) {
118 this->set(kNextEnumerationIndexIndex,
Smi::FromInt(index));
121template <
typename Derived,
typename Shape>
122int BaseNameDictionary<Derived, Shape>::next_enumeration_index() {
123 return Smi::ToInt(this->get(kNextEnumerationIndexIndex));
126template <
typename Derived,
typename Shape>
127void BaseNameDictionary<Derived, Shape>::SetHash(
int hash) {
132template <
typename Derived,
typename Shape>
133int BaseNameDictionary<Derived, Shape>::Hash()
const {
142 if (!
IsSmi(max_index_object))
return false;
149 if (!
IsSmi(max_index_object))
return 0;
150 uint32_t value =
static_cast<uint32_t
>(
Smi::ToInt(max_index_object));
158template <
typename Derived,
typename Shape>
159void Dictionary<Derived, Shape>::ClearEntry(
InternalIndex entry) {
162 Cast<Derived>(
this)->SetEntry(entry, the_hole, the_hole, details);
165template <
typename Derived,
typename Shape>
166void Dictionary<Derived, Shape>::SetEntry(InternalIndex entry,
169 PropertyDetails details) {
170 DCHECK(Dictionary::kEntrySize == 2 || Dictionary::kEntrySize == 3);
171 DCHECK(!IsName(
key) || details.dictionary_index() > 0);
172 int index = DerivedHashTable::EntryToIndex(entry);
175 this->set(index + Derived::kEntryKeyIndex,
key, mode);
176 this->set(index + Derived::kEntryValueIndex, value, mode);
177 if (Shape::kHasDetails) DetailsAtPut(entry, details);
180template <
typename Derived,
typename Shape>
181ObjectSlot Dictionary<Derived, Shape>::RawFieldOfValueAt(InternalIndex entry) {
182 return this->RawFieldOfElementAt(DerivedHashTable::EntryToIndex(entry) +
183 Derived::kEntryValueIndex);
186template <
typename Key>
187template <
typename Dictionary>
190 static_assert(Dictionary::kEntrySize == 3);
193 Dictionary::kEntryDetailsIndex)));
196template <
typename Key>
197template <
typename Dictionary>
201 static_assert(Dictionary::kEntrySize == 3);
202 dict->set(Dictionary::EntryToIndex(entry) + Dictionary::kEntryDetailsIndex,
211 return roots.global_dictionary_map();
216 return NameAt(cage_base, entry);
225 return roots.name_dictionary_map();
241 return CellAt(cage_base, entry);
246 DCHECK(IsPropertyCell(KeyAt(cage_base, entry), cage_base));
252 return NameAt(cage_base, entry);
257 return CellAt(cage_base, entry)->name(cage_base);
262 return ValueAt(cage_base, entry);
267 return CellAt(cage_base, entry)->value(cage_base);
273 set(EntryToIndex(entry) + kEntryKeyIndex, value);
274 DetailsAtPut(entry, details);
279 set(EntryToIndex(entry) + kEntryKeyIndex, the_hole);
283 set(EntryToIndex(entry), value);
302template <AllocationType allocation>
305 return isolate->factory()->NewNumberFromUint<allocation>(
key);
308template <AllocationType allocation>
311 return isolate->factory()->NewNumberFromUint<allocation>(
key);
315 return roots.number_dictionary_map();
319 return roots.simple_number_dictionary_map();
326 return *
key == other;
353template <AllocationType allocation>
360template <AllocationType allocation>
367template <
typename Dictionary>
371 return dict->CellAt(entry)->property_details();
374template <
typename Dictionary>
379 dict->CellAt(entry)->UpdatePropertyDetailsExceptCellType(value);
#define SLOW_DCHECK(condition)
static constexpr bool is_valid(T value)
static void DetailsAtPut(Tagged< Dictionary > dict, InternalIndex entry, PropertyDetails value)
static PropertyDetails DetailsAt(Tagged< Dictionary > dict, InternalIndex entry)
static bool IsMatch(DirectHandle< Name > key, Tagged< Object > other)
static uint32_t HashForObject(ReadOnlyRoots roots, Tagged< Object > object)
static DirectHandle< Object > AsHandle(Isolate *isolate, DirectHandle< Name > key)
static uint32_t Hash(ReadOnlyRoots roots, DirectHandle< Name > key)
static Tagged< Object > Unwrap(Tagged< Object > key)
static void DetailsAtPut(Tagged< Dictionary > dict, InternalIndex entry, PropertyDetails value)
static uint32_t HashForObject(ReadOnlyRoots roots, Tagged< Object > object)
static bool IsMatch(DirectHandle< Name > key, Tagged< Object > other)
static PropertyDetails DetailsAt(Tagged< Dictionary > dict, InternalIndex entry)
Tagged< Name > NameAt(InternalIndex entry)
void ClearEntry(InternalIndex entry)
Tagged< PropertyCell > CellAt(InternalIndex entry)
void ValueAtPut(InternalIndex entry, Tagged< Object > value)
void SetEntry(InternalIndex entry, Tagged< Object > key, Tagged< Object > value, PropertyDetails details)
Tagged< Object > ValueAt(InternalIndex entry)
static DirectHandle< Map > GetMap(RootsTable &roots)
Tagged< Name > NameAt(InternalIndex entry)
static const int kFlagsIndex
void set_flags(uint32_t flags)
static DirectHandle< Map > GetMap(RootsTable &roots)
static DirectHandle< Object > AsHandle(Isolate *isolate, uint32_t key)
static uint32_t HashForObject(ReadOnlyRoots roots, Tagged< Object > object)
static uint32_t Hash(ReadOnlyRoots roots, uint32_t key)
static bool IsMatch(uint32_t key, Tagged< Object > other)
bool requires_slow_elements()
uint32_t max_number_key()
static const int kMaxNumberKeyIndex
static DirectHandle< Map > GetMap(RootsTable &roots)
static const int kRequiresSlowElementsTagSize
static const int kRequiresSlowElementsMask
void set_requires_slow_elements()
static double NumberValue(Tagged< Number > obj)
static constexpr PropertyDetails Empty(PropertyCellType cell_type=PropertyCellType::kNoCell)
static DirectHandle< Map > GetMap(RootsTable &roots)
static constexpr int ToInt(const Tagged< Object > object)
static constexpr Tagged< Smi > FromInt(int value)
PerThreadAssertScopeDebugOnly< false, SAFEPOINTS_ASSERT, HEAP_ALLOCATION_ASSERT > DisallowGarbageCollection
SlotTraits::TObjectSlot ObjectSlot
bool IsNumber(Tagged< Object > obj)
ReadOnlyRoots GetReadOnlyRoots()
Tagged(T object) -> Tagged< T >
V8_INLINE bool GetIsolateFromHeapObject(Tagged< HeapObject > object, Isolate **isolate)
V8_INLINE constexpr bool IsSmi(TaggedImpl< kRefType, StorageType > obj)
too high values may cause the compiler to set high thresholds for inlining to as much as possible avoid inlined allocation of objects that cannot escape trace load stores from virtual maglev objects use TurboFan fast string builder analyze liveness of environment slots and zap dead values trace TurboFan load elimination emit data about basic block usage in builtins to this enable builtin reordering when run mksnapshot flag for emit warnings when applying builtin profile data verify register allocation in TurboFan randomly schedule instructions to stress dependency tracking enable store store elimination in TurboFan rewrite far to near simulate GC compiler thread race related to allow float parameters to be passed in simulator mode JS Wasm Run additional turbo_optimize_inlined_js_wasm_wrappers enable experimental feedback collection in generic lowering enable Turboshaft s WasmLoadElimination enable Turboshaft s low level load elimination for JS enable Turboshaft s escape analysis for string concatenation use enable Turbolev features that we want to ship in the not too far future trace individual Turboshaft reduction steps trace intermediate Turboshaft reduction steps invocation count threshold for early optimization Enables optimizations which favor memory size over execution speed Enables sampling allocation profiler with X as a sample interval min size of a semi the new space consists of two semi spaces max size of the Collect garbage after Collect garbage after keeps maps alive for< n > old space garbage collections print one detailed trace line in name
V8_INLINE PtrComprCageBase GetPtrComprCageBase()
return ComputeSeededHash(static_cast< uint32_t >(key), HashSeed(isolate))
bool IsUniqueName(Tagged< Name > obj)
uint64_t HashSeed(Isolate *isolate)
Tagged< To > Cast(Tagged< From > value, const v8::SourceLocation &loc=INIT_SOURCE_LOCATION_IN_DEBUG)
#define BIT_FIELD_ACCESSORS(holder, field, name, BitField)
#define DCHECK_NE(v1, v2)
#define DCHECK(condition)
#define DCHECK_LT(v1, v2)
#define DCHECK_EQ(v1, v2)