V8 Project
v8::internal::NameDictionary Class Reference

#include <objects.h>

+ Inheritance diagram for v8::internal::NameDictionary:
+ Collaboration diagram for v8::internal::NameDictionary:

Public Member Functions

void CopyEnumKeysTo (FixedArray *storage)
 
int FindEntry (Handle< Name > key)
 
- Public Member Functions inherited from v8::internal::Dictionary< NameDictionary, NameDictionaryShape, Handle< Name > >
ObjectValueAt (int entry)
 
void ValueAtPut (int entry, Object *value)
 
PropertyDetails DetailsAt (int entry)
 
void DetailsAtPut (int entry, PropertyDetails value)
 
void CopyValuesTo (FixedArray *elements)
 
int NumberOfElementsFilterAttributes (PropertyAttributes filter)
 
int NumberOfEnumElements ()
 
void CopyKeysTo (FixedArray *storage, PropertyAttributes filter, SortMode sort_mode)
 
void CopyKeysTo (FixedArray *storage, int index, PropertyAttributes filter, SortMode sort_mode)
 
void SetNextEnumerationIndex (int index)
 
int NextEnumerationIndex ()
 
ObjectSlowReverseLookup (Object *value)
 
void SetEntry (int entry, Handle< Object > key, Handle< Object > value)
 
void SetEntry (int entry, Handle< Object > key, Handle< Object > value, PropertyDetails details)
 
- Public Member Functions inherited from v8::internal::HashTable< Derived, Shape, Key >
uint32_t Hash (Key key)
 
uint32_t HashForObject (Key key, Object *object)
 
int NumberOfElements ()
 
int NumberOfDeletedElements ()
 
int Capacity ()
 
void ElementAdded ()
 
void ElementRemoved ()
 
void ElementsRemoved (int n)
 
ObjectKeyAt (int entry)
 
bool IsKey (Object *k)
 
void IteratePrefix (ObjectVisitor *visitor)
 
void IterateElements (ObjectVisitor *visitor)
 
 INLINE (static uint32_t GetProbeOffset(uint32_t n))
 
int FindEntry (Key key)
 
int FindEntry (Isolate *isolate, Key key)
 
void Rehash (Key key)
 
- Public Member Functions inherited from v8::internal::FixedArray
Objectget (int index)
 
void set (int index, Object *value)
 
bool is_the_hole (int index)
 
void set (int index, Smi *value)
 
void set (int index, Object *value, WriteBarrierMode mode)
 
void set_undefined (int index)
 
void set_null (int index)
 
void set_the_hole (int index)
 
Object ** GetFirstElementAddress ()
 
bool ContainsOnlySmisOrHoles ()
 
Object ** data_start ()
 
void FillWithHoles (int from, int to)
 
void Shrink (int length)
 
void CopyTo (int pos, FixedArray *dest, int dest_pos, int len)
 
Object ** RawFieldOfElementAt (int index)
 
void SwapPairs (FixedArray *numbers, int i, int j)
 
void SortPairs (FixedArray *numbers, uint32_t len)
 
- Public Member Functions inherited from v8::internal::FixedArrayBase
int length () const
 
void set_length (int value)
 
int synchronized_length () const
 
void synchronized_set_length (int value)
 
- Public Member Functions inherited from v8::internal::HeapObject
Mapmap () const
 
void set_map (Map *value)
 
void set_map_no_write_barrier (Map *value)
 
Mapsynchronized_map ()
 
MapWord synchronized_map_word () const
 
void synchronized_set_map (Map *value)
 
void synchronized_set_map_no_write_barrier (Map *value)
 
void synchronized_set_map_word (MapWord map_word)
 
MapWord map_word () const
 
void set_map_word (MapWord map_word)
 
HeapGetHeap () const
 
IsolateGetIsolate () const
 
Address address ()
 
void Iterate (ObjectVisitor *v)
 
void IterateBody (InstanceType type, int object_size, ObjectVisitor *v)
 
int Size ()
 
bool MayContainRawValues ()
 
int SizeFromMap (Map *map)
 
WriteBarrierMode GetWriteBarrierMode (const DisallowHeapAllocation &promise)
 
void HeapObjectShortPrint (OStream &os)
 
 STATIC_ASSERT (kMapOffset==Internals::kHeapObjectMapOffset)
 
- Public Member Functions inherited from v8::internal::Object
bool IsObject () const
 
 INLINE (bool IsFixedArrayBase() const)
 
 INLINE (bool IsExternal() const)
 
 INLINE (bool IsAccessorInfo() const)
 
 INLINE (bool IsStruct() const)
 
 INLINE (bool IsSpecObject()) const
 
 INLINE (bool IsSpecFunction()) const
 
 INLINE (bool IsTemplateInfo()) const
 
 INLINE (bool IsNameDictionary() const)
 
 INLINE (bool IsSeededNumberDictionary() const)
 
 INLINE (bool IsUnseededNumberDictionary() const)
 
 INLINE (bool IsOrderedHashSet() const)
 
 INLINE (bool IsOrderedHashMap() const)
 
bool IsCallable () const
 
 INLINE (bool IsUndefined() const)
 
 INLINE (bool IsNull() const)
 
 INLINE (bool IsTheHole() const)
 
 INLINE (bool IsException() const)
 
 INLINE (bool IsUninitialized() const)
 
 INLINE (bool IsTrue() const)
 
 INLINE (bool IsFalse() const)
 
 INLINE (bool IsArgumentsMarker() const)
 
 INLINE (bool IsFiller() const)
 
double Number ()
 
 INLINE (bool IsNaN() const)
 
 INLINE (bool IsMinusZero() const)
 
bool ToInt32 (int32_t *value)
 
bool ToUint32 (uint32_t *value)
 
Representation OptimalRepresentation ()
 
bool FitsRepresentation (Representation representation)
 
Handle< HeapTypeOptimalType (Isolate *isolate, Representation representation)
 
bool HasValidElements ()
 
bool HasSpecificClassOf (String *name)
 
bool BooleanValue ()
 
ObjectGetHash ()
 
bool SameValue (Object *other)
 
bool SameValueZero (Object *other)
 
bool ToArrayIndex (uint32_t *index)
 
bool IsStringObjectWithCharacterAt (uint32_t index)
 
void VerifyApiCallResultType ()
 
void ShortPrint (FILE *out=stdout)
 
void ShortPrint (StringStream *accumulator)
 

Static Public Member Functions

static void DoGenerateNewEnumerationIndices (Handle< NameDictionary > dictionary)
 
- Static Public Member Functions inherited from v8::internal::Dictionary< NameDictionary, NameDictionaryShape, Handle< Name > >
static Handle< ObjectDeleteProperty (Handle< NameDictionary > dictionary, int entry, JSObject::DeleteMode mode)
 
static MUST_USE_RESULT Handle< NameDictionaryShrink (Handle< NameDictionary > dictionary, Handle< Name > key)
 
static MUST_USE_RESULT Handle< NameDictionaryNew (Isolate *isolate, int at_least_space_for, PretenureFlag pretenure=NOT_TENURED)
 
static Handle< NameDictionaryEnsureCapacity (Handle< NameDictionary > obj, int n, Handle< Name > key)
 
static MUST_USE_RESULT Handle< NameDictionaryAdd (Handle< NameDictionary > dictionary, Handle< Name > key, Handle< Object > value, PropertyDetails details)
 
- Static Public Member Functions inherited from v8::internal::HashTable< Derived, Shape, Key >
static MUST_USE_RESULT Handle< Derived > New (Isolate *isolate, int at_least_space_for, MinimumCapacity capacity_option=USE_DEFAULT_MINIMUM_CAPACITY, PretenureFlag pretenure=NOT_TENURED)
 
static int ComputeCapacity (int at_least_space_for)
 
- Static Public Member Functions inherited from v8::internal::FixedArray
static Handle< Objectget (Handle< FixedArray > array, int index)
 
static Handle< FixedArrayCopySize (Handle< FixedArray > array, int new_length, PretenureFlag pretenure=NOT_TENURED)
 
static MUST_USE_RESULT MaybeHandle< FixedArrayAddKeysFromArrayLike (Handle< FixedArray > content, Handle< JSObject > array)
 
static MUST_USE_RESULT MaybeHandle< FixedArrayUnionOfKeys (Handle< FixedArray > first, Handle< FixedArray > second)
 
static int SizeFor (int length)
 
static int OffsetOfElementAt (int index)
 
- Static Public Member Functions inherited from v8::internal::HeapObject
static HeapObjectFromAddress (Address address)
 
static Object ** RawField (HeapObject *obj, int offset)
 
static void UpdateMapCodeCache (Handle< HeapObject > object, Handle< Name > name, Handle< Code > code)
 
- Static Public Member Functions inherited from v8::internal::Object
static Handle< ObjectNewStorageFor (Isolate *isolate, Handle< Object > object, Representation representation)
 
static Handle< ObjectWrapForRead (Isolate *isolate, Handle< Object > object, Representation representation)
 
static MaybeHandle< JSReceiverToObject (Isolate *isolate, Handle< Object > object)
 
static MaybeHandle< JSReceiverToObject (Isolate *isolate, Handle< Object > object, Handle< Context > context)
 
static MUST_USE_RESULT MaybeHandle< SmiToSmi (Isolate *isolate, Handle< Object > object)
 
static MUST_USE_RESULT MaybeHandle< ObjectGetProperty (LookupIterator *it)
 
static MUST_USE_RESULT MaybeHandle< ObjectSetProperty (Handle< Object > object, Handle< Name > key, Handle< Object > value, StrictMode strict_mode, StoreFromKeyed store_mode=MAY_BE_STORE_FROM_KEYED)
 
static MUST_USE_RESULT MaybeHandle< ObjectSetProperty (LookupIterator *it, Handle< Object > value, StrictMode strict_mode, StoreFromKeyed store_mode, StorePropertyMode data_store_mode=NORMAL_PROPERTY)
 
static MUST_USE_RESULT MaybeHandle< ObjectWriteToReadOnlyProperty (LookupIterator *it, Handle< Object > value, StrictMode strict_mode)
 
static Handle< ObjectSetDataProperty (LookupIterator *it, Handle< Object > value)
 
static MUST_USE_RESULT MaybeHandle< ObjectAddDataProperty (LookupIterator *it, Handle< Object > value, PropertyAttributes attributes, StrictMode strict_mode, StoreFromKeyed store_mode)
 
static MUST_USE_RESULT MaybeHandle< ObjectGetPropertyOrElement (Handle< Object > object, Handle< Name > key)
 
static MUST_USE_RESULT MaybeHandle< ObjectGetProperty (Isolate *isolate, Handle< Object > object, const char *key)
 
static MUST_USE_RESULT MaybeHandle< ObjectGetProperty (Handle< Object > object, Handle< Name > key)
 
static MUST_USE_RESULT MaybeHandle< ObjectGetPropertyWithAccessor (Handle< Object > receiver, Handle< Name > name, Handle< JSObject > holder, Handle< Object > structure)
 
static MUST_USE_RESULT MaybeHandle< ObjectSetPropertyWithAccessor (Handle< Object > receiver, Handle< Name > name, Handle< Object > value, Handle< JSObject > holder, Handle< Object > structure, StrictMode strict_mode)
 
static MUST_USE_RESULT MaybeHandle< ObjectGetPropertyWithDefinedGetter (Handle< Object > receiver, Handle< JSReceiver > getter)
 
static MUST_USE_RESULT MaybeHandle< ObjectSetPropertyWithDefinedSetter (Handle< Object > receiver, Handle< JSReceiver > setter, Handle< Object > value)
 
static MUST_USE_RESULT MaybeHandle< ObjectGetElement (Isolate *isolate, Handle< Object > object, uint32_t index)
 
static MUST_USE_RESULT MaybeHandle< ObjectGetElementWithReceiver (Isolate *isolate, Handle< Object > object, Handle< Object > receiver, uint32_t index)
 
static Handle< SmiGetOrCreateHash (Isolate *isolate, Handle< Object > object)
 

Private Types

typedef Dictionary< NameDictionary, NameDictionaryShape, Handle< Name > > DerivedDictionary
 

Additional Inherited Members

- Public Types inherited from v8::internal::Dictionary< NameDictionary, NameDictionaryShape, Handle< Name > >
enum  SortMode
 
- Public Types inherited from v8::internal::Object
enum  StoreFromKeyed { MAY_BE_STORE_FROM_KEYED , CERTAINLY_NOT_STORE_FROM_KEYED }
 
enum  StorePropertyMode { NORMAL_PROPERTY , SUPER_PROPERTY }
 
- Static Public Attributes inherited from v8::internal::HashTable< Derived, Shape, Key >
static const int kNumberOfElementsIndex = 0
 
static const int kNumberOfDeletedElementsIndex = 1
 
static const int kCapacityIndex = 2
 
static const int kPrefixStartIndex = 3
 
static const int kElementsStartIndex
 
static const int kEntrySize = Shape::kEntrySize
 
static const int kElementsStartOffset
 
static const int kCapacityOffset
 
static const int kNotFound = -1
 
static const int kMaxCapacity
 
- Static Public Attributes inherited from v8::internal::FixedArray
static const int kMaxSize = 128 * MB * kPointerSize
 
static const int kMaxLength = (kMaxSize - kHeaderSize) / kPointerSize
 
- Static Public Attributes inherited from v8::internal::FixedArrayBase
static const int kLengthOffset = HeapObject::kHeaderSize
 
static const int kHeaderSize = kLengthOffset + kPointerSize
 
- Static Public Attributes inherited from v8::internal::HeapObject
static const int kMapOffset = Object::kHeaderSize
 
static const int kHeaderSize = kMapOffset + kPointerSize
 
- Static Public Attributes inherited from v8::internal::Object
static const int kHeaderSize = 0
 
- Protected Types inherited from v8::internal::Dictionary< NameDictionary, NameDictionaryShape, Handle< Name > >
typedef HashTable< NameDictionary, NameDictionaryShape, Handle< Name > > DerivedHashTable
 
- Protected Member Functions inherited from v8::internal::HashTable< Derived, Shape, Key >
uint32_t FindInsertionEntry (uint32_t hash)
 
void SetNumberOfElements (int nof)
 
void SetNumberOfDeletedElements (int nod)
 
void SetCapacity (int capacity)
 
- Protected Member Functions inherited from v8::internal::HeapObject
void IteratePointers (ObjectVisitor *v, int start, int end)
 
void IteratePointer (ObjectVisitor *v, int offset)
 
void IterateNextCodeLink (ObjectVisitor *v, int offset)
 
- Static Protected Member Functions inherited from v8::internal::Dictionary< NameDictionary, NameDictionaryShape, Handle< Name > >
static MUST_USE_RESULT Handle< NameDictionaryAtPut (Handle< NameDictionary > dictionary, Handle< Name > key, Handle< Object > value)
 
static void AddEntry (Handle< NameDictionary > dictionary, Handle< Name > key, Handle< Object > value, PropertyDetails details, uint32_t hash)
 
static void GenerateNewEnumerationIndices (Handle< NameDictionary > dictionary)
 
- Static Protected Member Functions inherited from v8::internal::HashTable< Derived, Shape, Key >
static int EntryToIndex (int entry)
 
static uint32_t GetProbe (uint32_t hash, uint32_t number, uint32_t size)
 
static uint32_t FirstProbe (uint32_t hash, uint32_t size)
 
static uint32_t NextProbe (uint32_t last, uint32_t number, uint32_t size)
 
static MUST_USE_RESULT Handle< Derived > Shrink (Handle< Derived > table, Key key)
 
static MUST_USE_RESULT Handle< Derived > EnsureCapacity (Handle< Derived > table, int n, Key key, PretenureFlag pretenure=NOT_TENURED)
 
- Static Protected Member Functions inherited from v8::internal::FixedArray
static void NoWriteBarrierSet (FixedArray *array, int index, Object *value)
 
static void NoIncrementalWriteBarrierSet (FixedArray *array, int index, Object *value)
 
- Static Protected Attributes inherited from v8::internal::Dictionary< NameDictionary, NameDictionaryShape, Handle< Name > >
static const int kMaxNumberKeyIndex
 
static const int kNextEnumerationIndexIndex
 

Detailed Description

Definition at line 3620 of file objects.h.

Member Typedef Documentation

◆ DerivedDictionary

Member Function Documentation

◆ CopyEnumKeysTo()

void v8::internal::NameDictionary::CopyEnumKeysTo ( FixedArray storage)

Definition at line 15219 of file objects.cc.

15219  {
15220  int length = storage->length();
15221  int capacity = Capacity();
15222  int properties = 0;
15223  for (int i = 0; i < capacity; i++) {
15224  Object* k = KeyAt(i);
15225  if (IsKey(k) && !k->IsSymbol()) {
15226  PropertyDetails details = DetailsAt(i);
15227  if (details.IsDeleted() || details.IsDontEnum()) continue;
15228  storage->set(properties, Smi::FromInt(i));
15229  properties++;
15230  if (properties == length) break;
15231  }
15232  }
15233  CHECK_EQ(length, properties);
15234  EnumIndexComparator cmp(this);
15235  Smi** start = reinterpret_cast<Smi**>(storage->GetFirstElementAddress());
15236  std::sort(start, start + length, cmp);
15237  for (int i = 0; i < length; i++) {
15238  int index = Smi::cast(storage->get(i))->value();
15239  storage->set(i, KeyAt(index));
15240  }
15241 }
bool IsKey(Object *k)
Definition: objects.h:3255
Object * KeyAt(int entry)
Definition: objects.h:3251
static Smi * FromInt(int value)
Definition: objects-inl.h:1321
#define CHECK_EQ(expected, value)
Definition: logging.h:169
kSerializedDataOffset Object
Definition: objects-inl.h:5322

References CHECK_EQ, v8::internal::Smi::FromInt(), v8::internal::FixedArray::get(), v8::internal::FixedArray::GetFirstElementAddress(), v8::internal::FixedArrayBase::length(), and v8::internal::FixedArray::set().

+ Here is the call graph for this function:

◆ DoGenerateNewEnumerationIndices()

void v8::internal::NameDictionary::DoGenerateNewEnumerationIndices ( Handle< NameDictionary dictionary)
inlinestatic

Definition at line 6883 of file objects-inl.h.

6884  {
6886 }
static void GenerateNewEnumerationIndices(Handle< NameDictionary > dictionary)
Definition: objects.cc:14916

References v8::internal::Dictionary< NameDictionary, NameDictionaryShape, Handle< Name > >::GenerateNewEnumerationIndices().

Referenced by v8::internal::JSObject::MigrateSlowToFast().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ FindEntry()

int v8::internal::NameDictionary::FindEntry ( Handle< Name key)

Definition at line 13784 of file objects.cc.

13784  {
13785  if (!key->IsUniqueName()) {
13786  return DerivedHashTable::FindEntry(key);
13787  }
13788 
13789  // Optimized for unique names. Knowledge of the key type allows:
13790  // 1. Move the check if the key is unique out of the loop.
13791  // 2. Avoid comparing hash codes in unique-to-unique comparison.
13792  // 3. Detect a case when a dictionary key is not unique but the key is.
13793  // In case of positive result the dictionary key may be replaced by the
13794  // internalized string with minimal performance penalty. It gives a chance
13795  // to perform further lookups in code stubs (and significant performance
13796  // boost a certain style of code).
13797 
13798  // EnsureCapacity will guarantee the hash table is never full.
13799  uint32_t capacity = Capacity();
13800  uint32_t entry = FirstProbe(key->Hash(), capacity);
13801  uint32_t count = 1;
13802 
13803  while (true) {
13804  int index = EntryToIndex(entry);
13805  Object* element = get(index);
13806  if (element->IsUndefined()) break; // Empty entry.
13807  if (*key == element) return entry;
13808  if (!element->IsUniqueName() &&
13809  !element->IsTheHole() &&
13810  Name::cast(element)->Equals(*key)) {
13811  // Replace a key that is a non-internalized string by the equivalent
13812  // internalized string for faster further lookups.
13813  set(index, *key);
13814  return entry;
13815  }
13816  DCHECK(element->IsTheHole() || !Name::cast(element)->Equals(*key));
13817  entry = NextProbe(entry, count++, capacity);
13818  }
13819  return kNotFound;
13820 }
Object * get(int index)
Definition: objects-inl.h:2165
void set(int index, Object *value)
Definition: objects-inl.h:2190
static uint32_t NextProbe(uint32_t last, uint32_t number, uint32_t size)
Definition: objects.h:3341
static const int kNotFound
Definition: objects.h:3283
static int EntryToIndex(int entry)
Definition: objects.h:3306
static uint32_t FirstProbe(uint32_t hash, uint32_t size)
Definition: objects.h:3337
#define DCHECK(condition)
Definition: logging.h:205

References DCHECK, v8::internal::FixedArray::get(), and v8::internal::FixedArray::set().

Referenced by v8::internal::RUNTIME_FUNCTION(), and v8::internal::JSObject::SetNormalizedProperty().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

The documentation for this class was generated from the following files: