V8 Project
v8::internal::HashTable< Derived, Shape, Key > Class Template Reference

#include <objects.h>

+ Inheritance diagram for v8::internal::HashTable< Derived, Shape, Key >:
+ Collaboration diagram for v8::internal::HashTable< Derived, Shape, Key >:

Public Member Functions

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 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)
 

Static Public Attributes

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 Member Functions

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

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)
 

Private Member Functions

uint32_t EntryForProbe (Key key, Object *k, int probe, uint32_t expected)
 
void Swap (uint32_t entry1, uint32_t entry2, WriteBarrierMode mode)
 
void Rehash (Handle< Derived > new_table, Key key)
 

Friends

class ObjectHashTable
 

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 }
 

Detailed Description

template<typename Derived, typename Shape, typename Key>
class v8::internal::HashTable< Derived, Shape, Key >

Definition at line 3190 of file objects.h.

Member Function Documentation

◆ Capacity()

◆ ComputeCapacity()

template<typename Derived , typename Shape , typename Key >
int v8::internal::HashTable< Derived, Shape, Key >::ComputeCapacity ( int  at_least_space_for)
static

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

3099  {
3100  const int kMinCapacity = 32;
3101  int capacity = base::bits::RoundUpToPowerOfTwo32(at_least_space_for * 2);
3102  if (capacity < kMinCapacity) {
3103  capacity = kMinCapacity; // Guarantee min capacity.
3104  }
3105  return capacity;
3106 }
uint32_t RoundUpToPowerOfTwo32(uint32_t value)
Definition: bits.cc:12

References v8::base::bits::RoundUpToPowerOfTwo32().

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

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

◆ ElementAdded()

template<typename Derived , typename Shape , typename Key >
void v8::internal::HashTable< Derived, Shape, Key >::ElementAdded ( )
inline

Definition at line 3226 of file objects.h.

void SetNumberOfElements(int nof)
Definition: objects.h:3311

◆ ElementRemoved()

template<typename Derived , typename Shape , typename Key >
void v8::internal::HashTable< Derived, Shape, Key >::ElementRemoved ( )
inline

Definition at line 3230 of file objects.h.

3230  {
3233  }
void SetNumberOfDeletedElements(int nod)
Definition: objects.h:3316

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

+ Here is the caller graph for this function:

◆ ElementsRemoved()

template<typename Derived , typename Shape , typename Key >
void v8::internal::HashTable< Derived, Shape, Key >::ElementsRemoved ( int  n)
inline

Definition at line 3234 of file objects.h.

Referenced by v8::internal::MarkCompactCollector::AfterMarking(), and v8::internal::MarkCompactCollector::ProcessMapCaches().

+ Here is the caller graph for this function:

◆ EnsureCapacity()

template<typename Derived , typename Shape , typename Key >
Handle< Derived > v8::internal::HashTable< Derived, Shape, Key >::EnsureCapacity ( Handle< Derived >  table,
int  n,
Key  key,
PretenureFlag  pretenure = NOT_TENURED 
)
staticprotected

Definition at line 13928 of file objects.cc.

13932  {
13933  Isolate* isolate = table->GetIsolate();
13934  int capacity = table->Capacity();
13935  int nof = table->NumberOfElements() + n;
13936  int nod = table->NumberOfDeletedElements();
13937  // Return if:
13938  // 50% is still free after adding n elements and
13939  // at most 50% of the free elements are deleted elements.
13940  if (nod <= (capacity - nof) >> 1) {
13941  int needed_free = nof >> 1;
13942  if (nof + needed_free <= capacity) return table;
13943  }
13944 
13945  const int kMinCapacityForPretenure = 256;
13946  bool should_pretenure = pretenure == TENURED ||
13947  ((capacity > kMinCapacityForPretenure) &&
13948  !isolate->heap()->InNewSpace(*table));
13949  Handle<Derived> new_table = HashTable::New(
13950  isolate,
13951  nof * 2,
13953  should_pretenure ? TENURED : NOT_TENURED);
13954 
13955  table->Rehash(new_table, key);
13956  return new_table;
13957 }
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)
Definition: objects.cc:13756
@ USE_DEFAULT_MINIMUM_CAPACITY
Definition: globals.h:385

References v8::internal::Isolate::heap(), v8::internal::Heap::InNewSpace(), v8::internal::HashTable< Derived, Shape, Key >::New(), v8::internal::NOT_TENURED, v8::internal::TENURED, and v8::internal::USE_DEFAULT_MINIMUM_CAPACITY.

+ Here is the call graph for this function:

◆ EntryForProbe()

template<typename Derived , typename Shape , typename Key >
uint32_t v8::internal::HashTable< Derived, Shape, Key >::EntryForProbe ( Key  key,
Object k,
int  probe,
uint32_t  expected 
)
private

Definition at line 13859 of file objects.cc.

13863  {
13864  uint32_t hash = HashTable::HashForObject(key, k);
13865  uint32_t capacity = Capacity();
13866  uint32_t entry = FirstProbe(hash, capacity);
13867  for (int i = 1; i < probe; i++) {
13868  if (entry == expected) return expected;
13869  entry = NextProbe(entry, i, capacity);
13870  }
13871  return entry;
13872 }
static uint32_t NextProbe(uint32_t last, uint32_t number, uint32_t size)
Definition: objects.h:3341
uint32_t HashForObject(Key key, Object *object)
Definition: objects.h:3201
static uint32_t FirstProbe(uint32_t hash, uint32_t size)
Definition: objects.h:3337

References v8::internal::HashTable< Derived, Shape, Key >::HashForObject().

+ Here is the call graph for this function:

◆ EntryToIndex()

template<typename Derived , typename Shape , typename Key >
static int v8::internal::HashTable< Derived, Shape, Key >::EntryToIndex ( int  entry)
inlinestaticprotected

Definition at line 3306 of file objects.h.

3306  {
3307  return (entry * kEntrySize) + kElementsStartIndex;
3308  }
static const int kElementsStartIndex
Definition: objects.h:3274
static const int kEntrySize
Definition: objects.h:3276

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

+ Here is the caller graph for this function:

◆ FindEntry() [1/2]

template<typename Derived , typename Shape , typename Key >
int v8::internal::HashTable< Derived, Shape, Key >::FindEntry ( Isolate isolate,
Key  key 
)

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

3117  {
3118  uint32_t capacity = Capacity();
3119  uint32_t entry = FirstProbe(HashTable::Hash(key), capacity);
3120  uint32_t count = 1;
3121  // EnsureCapacity will guarantee the hash table is never full.
3122  while (true) {
3123  Object* element = KeyAt(entry);
3124  // Empty entry. Uses raw unchecked accessors because it is called by the
3125  // string table during bootstrapping.
3126  if (element == isolate->heap()->raw_unchecked_undefined_value()) break;
3127  if (element != isolate->heap()->raw_unchecked_the_hole_value() &&
3128  Shape::IsMatch(key, element)) return entry;
3129  entry = NextProbe(entry, count++, capacity);
3130  }
3131  return kNotFound;
3132 }
Object * KeyAt(int entry)
Definition: objects.h:3251
static const int kNotFound
Definition: objects.h:3283
uint32_t Hash(Key key)
Definition: objects.h:3193
kSerializedDataOffset Object
Definition: objects-inl.h:5322

References v8::internal::HashTable< Derived, Shape, Key >::Hash(), v8::internal::Isolate::heap(), and v8::internal::DescriptorArray::kNotFound.

+ Here is the call graph for this function:

◆ FindEntry() [2/2]

template<typename Derived , typename Shape , typename Key >
int v8::internal::HashTable< Derived, Shape, Key >::FindEntry ( Key  key)
inline

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

3110  {
3111  return FindEntry(GetIsolate(), key);
3112 }
Isolate * GetIsolate() const
Definition: objects-inl.h:1387

References v8::internal::HeapObject::GetIsolate().

Referenced by v8::internal::CopyDictionaryToDoubleElements(), v8::internal::CopyDictionaryToObjectElements(), v8::internal::PropertyICCompiler::FindPreMonomorphic(), v8::internal::JSObject::GetAccessor(), and v8::internal::UpdateGetterSetterInDictionary().

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

◆ FindInsertionEntry()

template<typename Derived , typename Shape , typename Key >
uint32_t v8::internal::HashTable< Derived, Shape, Key >::FindInsertionEntry ( uint32_t  hash)
protected

Definition at line 13993 of file objects.cc.

13993  {
13994  uint32_t capacity = Capacity();
13995  uint32_t entry = FirstProbe(hash, capacity);
13996  uint32_t count = 1;
13997  // EnsureCapacity will guarantee the hash table is never full.
13998  while (true) {
13999  Object* element = KeyAt(entry);
14000  if (element->IsUndefined() || element->IsTheHole()) break;
14001  entry = NextProbe(entry, count++, capacity);
14002  }
14003  return entry;
14004 }

◆ FirstProbe()

template<typename Derived , typename Shape , typename Key >
static uint32_t v8::internal::HashTable< Derived, Shape, Key >::FirstProbe ( uint32_t  hash,
uint32_t  size 
)
inlinestaticprotected

Definition at line 3337 of file objects.h.

3337  {
3338  return hash & (size - 1);
3339  }
enable harmony numeric enable harmony object literal extensions Optimize object size

References size.

◆ GetProbe()

template<typename Derived , typename Shape , typename Key >
static uint32_t v8::internal::HashTable< Derived, Shape, Key >::GetProbe ( uint32_t  hash,
uint32_t  number,
uint32_t  size 
)
inlinestaticprotected

Definition at line 3332 of file objects.h.

3332  {
3334  return (hash + GetProbeOffset(number)) & (size - 1);
3335  }
#define DCHECK(condition)
Definition: logging.h:205
bool IsPowerOfTwo32(uint32_t value)
Definition: bits.h:77

References DCHECK, v8::base::bits::IsPowerOfTwo32(), and size.

+ Here is the call graph for this function:

◆ Hash()

template<typename Derived , typename Shape , typename Key >
uint32_t v8::internal::HashTable< Derived, Shape, Key >::Hash ( Key  key)
inline

Definition at line 3193 of file objects.h.

3193  {
3194  if (Shape::UsesSeed) {
3195  return Shape::SeededHash(key, GetHeap()->HashSeed());
3196  } else {
3197  return Shape::Hash(key);
3198  }
3199  }
Heap * GetHeap() const
Definition: objects-inl.h:1379
static uint32_t Hash(RegisteredExtension *extension)

References v8::internal::Hash().

Referenced by v8::internal::HashTable< Derived, Shape, Key >::FindEntry().

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

◆ HashForObject()

template<typename Derived , typename Shape , typename Key >
uint32_t v8::internal::HashTable< Derived, Shape, Key >::HashForObject ( Key  key,
Object object 
)
inline

Definition at line 3201 of file objects.h.

3201  {
3202  if (Shape::UsesSeed) {
3203  return Shape::SeededHashForObject(key, GetHeap()->HashSeed(), object);
3204  } else {
3205  return Shape::HashForObject(key, object);
3206  }
3207  }

Referenced by v8::internal::HashTable< Derived, Shape, Key >::EntryForProbe(), and v8::internal::HashTable< Derived, Shape, Key >::Rehash().

+ Here is the caller graph for this function:

◆ INLINE()

template<typename Derived , typename Shape , typename Key >
v8::internal::HashTable< Derived, Shape, Key >::INLINE ( static uint32_t   GetProbeOffsetuint32_t n)
inline

Definition at line 3266 of file objects.h.

3266  {
3267  return (n + n * n) >> 1;
3268  }

◆ IsKey()

template<typename Derived , typename Shape , typename Key >
bool v8::internal::HashTable< Derived, Shape, Key >::IsKey ( Object k)
inline

Definition at line 3255 of file objects.h.

3255  {
3256  return !k->IsTheHole() && !k->IsUndefined();
3257  }

Referenced by v8::internal::MarkCompactCollector::ClearNonLiveReferences(), v8::internal::Dictionary< Derived, Shape, Key >::CopyValuesTo(), v8::internal::V8HeapExplorer::ExtractElementReferences(), v8::internal::V8HeapExplorer::ExtractPropertyReferences(), v8::internal::FreezeDictionary(), v8::internal::PatchIncrementalMarkingRecordWriteStubs(), and v8::internal::Dictionary< Derived, Shape, Key >::SlowReverseLookup().

+ Here is the caller graph for this function:

◆ IterateElements()

template<typename Derived , typename Shape , typename Key >
void v8::internal::HashTable< Derived, Shape, Key >::IterateElements ( ObjectVisitor visitor)

Definition at line 13748 of file objects.cc.

13748  {
13749  IteratePointers(v,
13752 }
static const int kHeaderSize
Definition: objects.h:2393
static const int kElementsStartOffset
Definition: objects.h:3277
void IteratePointers(ObjectVisitor *v, int start, int end)
Definition: objects-inl.h:1499
const int kPointerSize
Definition: globals.h:129

References v8::internal::HeapObject::IteratePointers(), v8::internal::FixedArrayBase::kHeaderSize, v8::internal::kPointerSize, and v8::internal::FixedArrayBase::length().

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

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

◆ IteratePrefix()

template<typename Derived , typename Shape , typename Key >
void v8::internal::HashTable< Derived, Shape, Key >::IteratePrefix ( ObjectVisitor visitor)

Definition at line 13742 of file objects.cc.

13742  {
13744 }

References v8::internal::HeapObject::IteratePointers().

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

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

◆ KeyAt()

template<typename Derived , typename Shape , typename Key >
Object* v8::internal::HashTable< Derived, Shape, Key >::KeyAt ( int  entry)
inline

◆ New()

template<typename Derived , typename Shape , typename Key >
template Handle< NameDictionary > v8::internal::HashTable< Derived, Shape, Key >::New ( Isolate isolate,
int  at_least_space_for,
MinimumCapacity  capacity_option = USE_DEFAULT_MINIMUM_CAPACITY,
PretenureFlag  pretenure = NOT_TENURED 
)
static

Definition at line 13756 of file objects.cc.

13760  {
13761  DCHECK(0 <= at_least_space_for);
13762  DCHECK(!capacity_option || base::bits::IsPowerOfTwo32(at_least_space_for));
13763  int capacity = (capacity_option == USE_CUSTOM_MINIMUM_CAPACITY)
13764  ? at_least_space_for
13765  : ComputeCapacity(at_least_space_for);
13766  if (capacity > HashTable::kMaxCapacity) {
13767  v8::internal::Heap::FatalProcessOutOfMemory("invalid table size", true);
13768  }
13769 
13770  Factory* factory = isolate->factory();
13771  int length = EntryToIndex(capacity);
13772  Handle<FixedArray> array = factory->NewFixedArray(length, pretenure);
13773  array->set_map_no_write_barrier(*factory->hash_table_map());
13774  Handle<Derived> table = Handle<Derived>::cast(array);
13775 
13776  table->SetNumberOfElements(0);
13777  table->SetNumberOfDeletedElements(0);
13778  table->SetCapacity(capacity);
13779  return table;
13780 }
static Handle< T > cast(Handle< S > that)
Definition: handles.h:116
static int ComputeCapacity(int at_least_space_for)
Definition: objects-inl.h:3099
static const int kMaxCapacity
Definition: objects.h:3288
static void FatalProcessOutOfMemory(const char *location, bool take_snapshot=false)
Definition: heap.cc:5376
@ USE_CUSTOM_MINIMUM_CAPACITY
Definition: globals.h:386

References v8::internal::Handle< T >::cast(), DCHECK, v8::internal::Isolate::factory(), v8::internal::Heap::FatalProcessOutOfMemory(), v8::base::bits::IsPowerOfTwo32(), v8::internal::HashTable< Derived, Shape, Key >::kMaxCapacity, v8::internal::FixedArrayBase::length(), and v8::internal::USE_CUSTOM_MINIMUM_CAPACITY.

Referenced by v8::internal::HashTable< Derived, Shape, Key >::EnsureCapacity(), and v8::internal::HashTable< Derived, Shape, Key >::Shrink().

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

◆ NextProbe()

template<typename Derived , typename Shape , typename Key >
static uint32_t v8::internal::HashTable< Derived, Shape, Key >::NextProbe ( uint32_t  last,
uint32_t  number,
uint32_t  size 
)
inlinestaticprotected

Definition at line 3341 of file objects.h.

3342  {
3343  return (last + number) & (size - 1);
3344  }

References size.

◆ NumberOfDeletedElements()

template<typename Derived , typename Shape , typename Key >
int v8::internal::HashTable< Derived, Shape, Key >::NumberOfDeletedElements ( )
inline

Definition at line 3215 of file objects.h.

3215  {
3216  return Smi::cast(get(kNumberOfDeletedElementsIndex))->value();
3217  }
static const int kNumberOfDeletedElementsIndex
Definition: objects.h:3271

◆ NumberOfElements()

template<typename Derived , typename Shape , typename Key >
int v8::internal::HashTable< Derived, Shape, Key >::NumberOfElements ( )
inline

Definition at line 3210 of file objects.h.

3210  {
3211  return Smi::cast(get(kNumberOfElementsIndex))->value();
3212  }
static const int kNumberOfElementsIndex
Definition: objects.h:3270

Referenced by v8::internal::JSObject::GetElementsCapacityAndUsage(), and v8::internal::MarkCompactCollector::ProcessMapCaches().

+ Here is the caller graph for this function:

◆ Rehash() [1/2]

template<typename Derived , typename Shape , typename Key >
void v8::internal::HashTable< Derived, Shape, Key >::Rehash ( Handle< Derived >  new_table,
Key  key 
)
private

Definition at line 13824 of file objects.cc.

13826  {
13827  DCHECK(NumberOfElements() < new_table->Capacity());
13828 
13829  DisallowHeapAllocation no_gc;
13830  WriteBarrierMode mode = new_table->GetWriteBarrierMode(no_gc);
13831 
13832  // Copy prefix to new array.
13833  for (int i = kPrefixStartIndex;
13834  i < kPrefixStartIndex + Shape::kPrefixSize;
13835  i++) {
13836  new_table->set(i, get(i), mode);
13837  }
13838 
13839  // Rehash the elements.
13840  int capacity = Capacity();
13841  for (int i = 0; i < capacity; i++) {
13842  uint32_t from_index = EntryToIndex(i);
13843  Object* k = get(from_index);
13844  if (IsKey(k)) {
13845  uint32_t hash = HashTable::HashForObject(key, k);
13846  uint32_t insertion_index =
13847  EntryToIndex(new_table->FindInsertionEntry(hash));
13848  for (int j = 0; j < Shape::kEntrySize; j++) {
13849  new_table->set(insertion_index + j, get(from_index + j), mode);
13850  }
13851  }
13852  }
13853  new_table->SetNumberOfElements(NumberOfElements());
13854  new_table->SetNumberOfDeletedElements(0);
13855 }
bool IsKey(Object *k)
Definition: objects.h:3255
static const int kPrefixStartIndex
Definition: objects.h:3273
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long mode(MIPS only)") DEFINE_BOOL(enable_always_align_csp
PerThreadAssertScopeDebugOnly< HEAP_ALLOCATION_ASSERT, false > DisallowHeapAllocation
Definition: assert-scope.h:110

References DCHECK, v8::internal::FixedArray::get(), v8::internal::HashTable< Derived, Shape, Key >::HashForObject(), and mode().

+ Here is the call graph for this function:

◆ Rehash() [2/2]

template<typename Derived , typename Shape , typename Key >
void v8::internal::HashTable< Derived, Shape, Key >::Rehash ( Key  key)

Definition at line 13895 of file objects.cc.

13895  {
13896  DisallowHeapAllocation no_gc;
13898  uint32_t capacity = Capacity();
13899  bool done = false;
13900  for (int probe = 1; !done; probe++) {
13901  // All elements at entries given by one of the first _probe_ probes
13902  // are placed correctly. Other elements might need to be moved.
13903  done = true;
13904  for (uint32_t current = 0; current < capacity; current++) {
13905  Object* current_key = get(EntryToIndex(current));
13906  if (IsKey(current_key)) {
13907  uint32_t target = EntryForProbe(key, current_key, probe, current);
13908  if (current == target) continue;
13909  Object* target_key = get(EntryToIndex(target));
13910  if (!IsKey(target_key) ||
13911  EntryForProbe(key, target_key, probe, target) != target) {
13912  // Put the current element into the correct position.
13913  Swap(current, target, mode);
13914  // The other element will be processed on the next iteration.
13915  current--;
13916  } else {
13917  // The place for the current element is occupied. Leave the element
13918  // for the next probe.
13919  done = false;
13920  }
13921  }
13922  }
13923  }
13924 }
uint32_t EntryForProbe(Key key, Object *k, int probe, uint32_t expected)
Definition: objects.cc:13859
void Swap(uint32_t entry1, uint32_t entry2, WriteBarrierMode mode)
Definition: objects.cc:13876
WriteBarrierMode GetWriteBarrierMode(const DisallowHeapAllocation &promise)
Definition: objects-inl.h:2660

References v8::internal::FixedArray::get(), v8::internal::HeapObject::GetWriteBarrierMode(), and mode().

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

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

◆ SetCapacity()

template<typename Derived , typename Shape , typename Key >
void v8::internal::HashTable< Derived, Shape, Key >::SetCapacity ( int  capacity)
inlineprotected

Definition at line 3321 of file objects.h.

3321  {
3322  // To scale a computed hash code to fit within the hash table, we
3323  // use bit-wise AND with a mask, so the capacity must be positive
3324  // and non-zero.
3325  DCHECK(capacity > 0);
3326  DCHECK(capacity <= kMaxCapacity);
3327  set(kCapacityIndex, Smi::FromInt(capacity));
3328  }
void set(int index, Object *value)
Definition: objects-inl.h:2190
static Smi * FromInt(int value)
Definition: objects-inl.h:1321

References DCHECK, and v8::internal::Smi::FromInt().

+ Here is the call graph for this function:

◆ SetNumberOfDeletedElements()

template<typename Derived , typename Shape , typename Key >
void v8::internal::HashTable< Derived, Shape, Key >::SetNumberOfDeletedElements ( int  nod)
inlineprotected

Definition at line 3316 of file objects.h.

3316  {
3318  }

References v8::internal::Smi::FromInt().

+ Here is the call graph for this function:

◆ SetNumberOfElements()

template<typename Derived , typename Shape , typename Key >
void v8::internal::HashTable< Derived, Shape, Key >::SetNumberOfElements ( int  nof)
inlineprotected

Definition at line 3311 of file objects.h.

3311  {
3313  }

References v8::internal::Smi::FromInt().

+ Here is the call graph for this function:

◆ Shrink()

template<typename Derived , typename Shape , typename Key >
template Handle< SeededNumberDictionary > v8::internal::HashTable< Derived, Shape, Key >::Shrink ( Handle< Derived >  table,
Key  key 
)
staticprotected

Definition at line 13961 of file objects.cc.

13962  {
13963  int capacity = table->Capacity();
13964  int nof = table->NumberOfElements();
13965 
13966  // Shrink to fit the number of elements if only a quarter of the
13967  // capacity is filled with elements.
13968  if (nof > (capacity >> 2)) return table;
13969  // Allocate a new dictionary with room for at least the current
13970  // number of elements. The allocation method will make sure that
13971  // there is extra room in the dictionary for additions. Don't go
13972  // lower than room for 16 elements.
13973  int at_least_room_for = nof;
13974  if (at_least_room_for < 16) return table;
13975 
13976  Isolate* isolate = table->GetIsolate();
13977  const int kMinCapacityForPretenure = 256;
13978  bool pretenure =
13979  (at_least_room_for > kMinCapacityForPretenure) &&
13980  !isolate->heap()->InNewSpace(*table);
13981  Handle<Derived> new_table = HashTable::New(
13982  isolate,
13983  at_least_room_for,
13985  pretenure ? TENURED : NOT_TENURED);
13986 
13987  table->Rehash(new_table, key);
13988  return new_table;
13989 }

References v8::internal::Isolate::heap(), v8::internal::Heap::InNewSpace(), v8::internal::HashTable< Derived, Shape, Key >::New(), v8::internal::NOT_TENURED, v8::internal::TENURED, and v8::internal::USE_DEFAULT_MINIMUM_CAPACITY.

+ Here is the call graph for this function:

◆ Swap()

template<typename Derived , typename Shape , typename Key >
void v8::internal::HashTable< Derived, Shape, Key >::Swap ( uint32_t  entry1,
uint32_t  entry2,
WriteBarrierMode  mode 
)
private

Definition at line 13876 of file objects.cc.

13878  {
13879  int index1 = EntryToIndex(entry1);
13880  int index2 = EntryToIndex(entry2);
13881  Object* temp[Shape::kEntrySize];
13882  for (int j = 0; j < Shape::kEntrySize; j++) {
13883  temp[j] = get(index1 + j);
13884  }
13885  for (int j = 0; j < Shape::kEntrySize; j++) {
13886  set(index1 + j, get(index2 + j), mode);
13887  }
13888  for (int j = 0; j < Shape::kEntrySize; j++) {
13889  set(index2 + j, temp[j], mode);
13890  }
13891 }

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

+ Here is the call graph for this function:

Friends And Related Function Documentation

◆ ObjectHashTable

template<typename Derived , typename Shape , typename Key >
friend class ObjectHashTable
friend

Definition at line 3299 of file objects.h.

Member Data Documentation

◆ kCapacityIndex

template<typename Derived , typename Shape , typename Key >
const int v8::internal::HashTable< Derived, Shape, Key >::kCapacityIndex = 2
static

Definition at line 3272 of file objects.h.

◆ kCapacityOffset

template<typename Derived , typename Shape , typename Key >
const int v8::internal::HashTable< Derived, Shape, Key >::kCapacityOffset
static
Initial value:

Definition at line 3279 of file objects.h.

◆ kElementsStartIndex

template<typename Derived , typename Shape , typename Key >
const int v8::internal::HashTable< Derived, Shape, Key >::kElementsStartIndex
static
Initial value:
=
kPrefixStartIndex + Shape::kPrefixSize

Definition at line 3274 of file objects.h.

◆ kElementsStartOffset

template<typename Derived , typename Shape , typename Key >
const int v8::internal::HashTable< Derived, Shape, Key >::kElementsStartOffset
static
Initial value:

Definition at line 3277 of file objects.h.

◆ kEntrySize

template<typename Derived , typename Shape , typename Key >
const int v8::internal::HashTable< Derived, Shape, Key >::kEntrySize = Shape::kEntrySize
static

◆ kMaxCapacity

template<typename Derived , typename Shape , typename Key >
const int v8::internal::HashTable< Derived, Shape, Key >::kMaxCapacity
static
Initial value:

Definition at line 3288 of file objects.h.

Referenced by v8::internal::HashTable< Derived, Shape, Key >::New().

◆ kNotFound

◆ kNumberOfDeletedElementsIndex

template<typename Derived , typename Shape , typename Key >
const int v8::internal::HashTable< Derived, Shape, Key >::kNumberOfDeletedElementsIndex = 1
static

Definition at line 3271 of file objects.h.

◆ kNumberOfElementsIndex

template<typename Derived , typename Shape , typename Key >
const int v8::internal::HashTable< Derived, Shape, Key >::kNumberOfElementsIndex = 0
static

Definition at line 3270 of file objects.h.

◆ kPrefixStartIndex

template<typename Derived , typename Shape , typename Key >
const int v8::internal::HashTable< Derived, Shape, Key >::kPrefixStartIndex = 3
static

Definition at line 3273 of file objects.h.


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