V8 Project
v8::internal::ObjectHashTable Class Reference

#include <objects.h>

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

Public Member Functions

ObjectLookup (Handle< Object > key)
 
- Public Member Functions inherited from v8::internal::HashTable< ObjectHashTable, ObjectHashTableShape, Handle< Object > >
uint32_t Hash (Handle< Object > key)
 
uint32_t HashForObject (Handle< Object > 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 (Handle< Object > key)
 
int FindEntry (Isolate *isolate, Handle< Object > key)
 
void Rehash (Handle< Object > 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 MUST_USE_RESULT Handle< ObjectHashTableShrink (Handle< ObjectHashTable > table, Handle< Object > key)
 
static Handle< ObjectHashTablePut (Handle< ObjectHashTable > table, Handle< Object > key, Handle< Object > value)
 
static Handle< ObjectHashTableRemove (Handle< ObjectHashTable > table, Handle< Object > key, bool *was_present)
 
- Static Public Member Functions inherited from v8::internal::HashTable< ObjectHashTable, ObjectHashTableShape, Handle< Object > >
static MUST_USE_RESULT Handle< ObjectHashTableNew (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 HashTable< ObjectHashTable, ObjectHashTableShape, Handle< Object > > DerivedHashTable
 

Private Member Functions

void AddEntry (int entry, Object *key, Object *value)
 
void RemoveEntry (int entry)
 

Static Private Member Functions

static int EntryToValueIndex (int entry)
 

Friends

class MarkCompactCollector
 

Additional Inherited Members

- 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< ObjectHashTable, ObjectHashTableShape, Handle< Object > >
static const int kNumberOfElementsIndex
 
static const int kNumberOfDeletedElementsIndex
 
static const int kCapacityIndex
 
static const int kPrefixStartIndex
 
static const int kElementsStartIndex
 
static const int kEntrySize
 
static const int kElementsStartOffset
 
static const int kCapacityOffset
 
static const int kNotFound
 
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 Member Functions inherited from v8::internal::HashTable< ObjectHashTable, ObjectHashTableShape, Handle< Object > >
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::HashTable< ObjectHashTable, ObjectHashTableShape, Handle< Object > >
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< ObjectHashTableShrink (Handle< ObjectHashTable > table, Handle< Object > key)
 
static MUST_USE_RESULT Handle< ObjectHashTableEnsureCapacity (Handle< ObjectHashTable > table, int n, Handle< Object > 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)
 

Detailed Description

Definition at line 3757 of file objects.h.

Member Typedef Documentation

◆ DerivedHashTable

Member Function Documentation

◆ AddEntry()

void v8::internal::ObjectHashTable::AddEntry ( int  entry,
Object key,
Object value 
)
private

Definition at line 15353 of file objects.cc.

15353  {
15354  set(EntryToIndex(entry), key);
15355  set(EntryToIndex(entry) + 1, value);
15356  ElementAdded();
15357 }
void set(int index, Object *value)
Definition: objects-inl.h:2190

References v8::internal::FixedArray::set().

+ Here is the call graph for this function:

◆ EntryToValueIndex()

static int v8::internal::ObjectHashTable::EntryToValueIndex ( int  entry)
inlinestaticprivate

Definition at line 3791 of file objects.h.

3791  {
3792  return EntryToIndex(entry) + 1;
3793  }

Referenced by v8::internal::MarkCompactCollector::ProcessWeakCollections().

+ Here is the caller graph for this function:

◆ Lookup()

Object * v8::internal::ObjectHashTable::Lookup ( Handle< Object key)

Definition at line 15287 of file objects.cc.

15287  {
15288  DisallowHeapAllocation no_gc;
15289  DCHECK(IsKey(*key));
15290 
15291  // If the object does not have an identity hash, it was never used as a key.
15292  Object* hash = key->GetHash();
15293  if (hash->IsUndefined()) {
15294  return GetHeap()->the_hole_value();
15295  }
15296  int entry = FindEntry(key);
15297  if (entry == kNotFound) return GetHeap()->the_hole_value();
15298  return get(EntryToIndex(entry) + 1);
15299 }
Object * get(int index)
Definition: objects-inl.h:2165
Heap * GetHeap() const
Definition: objects-inl.h:1379
#define DCHECK(condition)
Definition: logging.h:205
PerThreadAssertScopeDebugOnly< HEAP_ALLOCATION_ASSERT, false > DisallowHeapAllocation
Definition: assert-scope.h:110
kSerializedDataOffset Object
Definition: objects-inl.h:5322

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

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

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

◆ Put()

Handle< ObjectHashTable > v8::internal::ObjectHashTable::Put ( Handle< ObjectHashTable table,
Handle< Object key,
Handle< Object value 
)
static

Definition at line 15302 of file objects.cc.

15304  {
15305  DCHECK(table->IsKey(*key));
15306  DCHECK(!value->IsTheHole());
15307 
15308  Isolate* isolate = table->GetIsolate();
15309 
15310  // Make sure the key object has an identity hash code.
15311  Handle<Smi> hash = Object::GetOrCreateHash(isolate, key);
15312 
15313  int entry = table->FindEntry(key);
15314 
15315  // Key is already in table, just overwrite value.
15316  if (entry != kNotFound) {
15317  table->set(EntryToIndex(entry) + 1, *value);
15318  return table;
15319  }
15320 
15321  // Check whether the hash table should be extended.
15322  table = EnsureCapacity(table, 1, key);
15323  table->AddEntry(table->FindInsertionEntry(hash->value()),
15324  *key,
15325  *value);
15326  return table;
15327 }
static MUST_USE_RESULT Handle< ObjectHashTable > EnsureCapacity(Handle< ObjectHashTable > table, int n, Handle< Object > key, PretenureFlag pretenure=NOT_TENURED)
Definition: objects.cc:13928
static Handle< Smi > GetOrCreateHash(Isolate *isolate, Handle< Object > object)
Definition: objects.cc:856

References DCHECK, and v8::internal::Object::GetOrCreateHash().

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

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

◆ Remove()

Handle< ObjectHashTable > v8::internal::ObjectHashTable::Remove ( Handle< ObjectHashTable table,
Handle< Object key,
bool was_present 
)
static

Definition at line 15330 of file objects.cc.

15332  {
15333  DCHECK(table->IsKey(*key));
15334 
15335  Object* hash = key->GetHash();
15336  if (hash->IsUndefined()) {
15337  *was_present = false;
15338  return table;
15339  }
15340 
15341  int entry = table->FindEntry(key);
15342  if (entry == kNotFound) {
15343  *was_present = false;
15344  return table;
15345  }
15346 
15347  *was_present = true;
15348  table->RemoveEntry(entry);
15349  return Shrink(table, key);
15350 }
static MUST_USE_RESULT Handle< ObjectHashTable > Shrink(Handle< ObjectHashTable > table, Handle< Object > key)
Definition: objects-inl.h:6911

References DCHECK, and v8::internal::FixedArray::Shrink().

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

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

◆ RemoveEntry()

void v8::internal::ObjectHashTable::RemoveEntry ( int  entry)
private

Definition at line 15360 of file objects.cc.

References v8::internal::FixedArray::set_the_hole().

Referenced by v8::internal::MarkCompactCollector::ClearWeakCollections().

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

◆ Shrink()

Handle< ObjectHashTable > v8::internal::ObjectHashTable::Shrink ( Handle< ObjectHashTable table,
Handle< Object key 
)
inlinestatic

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

6912  {
6913  return DerivedHashTable::Shrink(table, key);
6914 }
static MUST_USE_RESULT Handle< ObjectHashTable > Shrink(Handle< ObjectHashTable > table, Handle< Object > key)
Definition: objects.cc:13961

References v8::internal::HashTable< ObjectHashTable, ObjectHashTableShape, Handle< Object > >::Shrink().

+ Here is the call graph for this function:

Friends And Related Function Documentation

◆ MarkCompactCollector

friend class MarkCompactCollector
friend

Definition at line 3785 of file objects.h.


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