V8 Project
v8::internal::StringTable Class Reference

#include <objects.h>

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

Static Public Member Functions

static Handle< StringLookupString (Isolate *isolate, Handle< String > key)
 
static Handle< StringLookupKey (Isolate *isolate, HashTableKey *key)
 
static MUST_USE_RESULT MaybeHandle< StringInternalizeStringIfExists (Isolate *isolate, Handle< String > string)
 
static MUST_USE_RESULT MaybeHandle< StringLookupStringIfExists (Isolate *isolate, Handle< String > str)
 
static MUST_USE_RESULT MaybeHandle< StringLookupTwoCharsStringIfExists (Isolate *isolate, uint16_t c1, uint16_t c2)
 
- Static Public Member Functions inherited from v8::internal::HashTable< StringTable, StringTableShape, HashTableKey * >
static MUST_USE_RESULT Handle< StringTableNew (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 Member Functions

 DISALLOW_IMPLICIT_CONSTRUCTORS (StringTable)
 

Friends

template<bool seq_one_byte>
class JsonParser
 

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 }
 
- Public Member Functions inherited from v8::internal::HashTable< StringTable, StringTableShape, HashTableKey * >
uint32_t Hash (HashTableKey * key)
 
uint32_t HashForObject (HashTableKey * 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 (HashTableKey * key)
 
int FindEntry (Isolate *isolate, HashTableKey * key)
 
void Rehash (HashTableKey * 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 Attributes inherited from v8::internal::HashTable< StringTable, StringTableShape, HashTableKey * >
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< StringTable, StringTableShape, HashTableKey * >
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< StringTable, StringTableShape, HashTableKey * >
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< StringTableShrink (Handle< StringTable > table, HashTableKey * key)
 
static MUST_USE_RESULT Handle< StringTableEnsureCapacity (Handle< StringTable > table, int n, HashTableKey * 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 3411 of file objects.h.

Member Function Documentation

◆ DISALLOW_IMPLICIT_CONSTRUCTORS()

v8::internal::StringTable::DISALLOW_IMPLICIT_CONSTRUCTORS ( StringTable  )
private

◆ InternalizeStringIfExists()

MaybeHandle< String > v8::internal::StringTable::InternalizeStringIfExists ( Isolate isolate,
Handle< String string 
)
static

Definition at line 14663 of file objects.cc.

14665  {
14666  if (string->IsInternalizedString()) {
14667  return string;
14668  }
14669  return LookupStringIfExists(isolate, string);
14670 }
static MUST_USE_RESULT MaybeHandle< String > LookupStringIfExists(Isolate *isolate, Handle< String > str)
Definition: objects.cc:14673

Referenced by v8::internal::KeyedLookupCache::Update(), and v8::internal::ContextSlotCache::Update().

+ Here is the caller graph for this function:

◆ LookupKey()

Handle< String > v8::internal::StringTable::LookupKey ( Isolate isolate,
HashTableKey key 
)
static

Definition at line 14713 of file objects.cc.

14713  {
14714  Handle<StringTable> table = isolate->factory()->string_table();
14715  int entry = table->FindEntry(key);
14716 
14717  // String already in table.
14718  if (entry != kNotFound) {
14719  return handle(String::cast(table->KeyAt(entry)), isolate);
14720  }
14721 
14722  // Adding new string. Grow table if needed.
14723  table = StringTable::EnsureCapacity(table, 1, key);
14724 
14725  // Create string object.
14726  Handle<Object> string = key->AsHandle(isolate);
14727  // There must be no attempts to internalize strings that could throw
14728  // InvalidStringLength error.
14729  CHECK(!string.is_null());
14730 
14731  // Add the new string and return it along with the string table.
14732  entry = table->FindInsertionEntry(key->Hash());
14733  table->set(EntryToIndex(entry), *string);
14734  table->ElementAdded();
14735 
14736  isolate->factory()->set_string_table(table);
14737  return Handle<String>::cast(string);
14738 }
static Handle< T > cast(Handle< S > that)
Definition: handles.h:116
static MUST_USE_RESULT Handle< StringTable > EnsureCapacity(Handle< StringTable > table, int n, HashTableKey * key, PretenureFlag pretenure=NOT_TENURED)
Definition: objects.cc:13928
#define CHECK(condition)
Definition: logging.h:36
Handle< T > handle(T *t, Isolate *isolate)
Definition: handles.h:146

References v8::internal::HashTableKey::AsHandle(), v8::internal::Handle< T >::cast(), CHECK, v8::internal::HashTable< StringTable, StringTableShape, HashTableKey * >::EnsureCapacity(), v8::internal::Isolate::factory(), v8::internal::handle(), and v8::internal::HashTableKey::Hash().

Referenced by v8::internal::AstRawString::Internalize(), and v8::internal::Deserializer::ProcessNewObjectFromSerializedCode().

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

◆ LookupString()

Handle< String > v8::internal::StringTable::LookupString ( Isolate isolate,
Handle< String key 
)
static

Definition at line 14706 of file objects.cc.

14707  {
14708  InternalizedStringKey key(string);
14709  return LookupKey(isolate, &key);
14710 }
static Handle< String > LookupKey(Isolate *isolate, HashTableKey *key)
Definition: objects.cc:14713

◆ LookupStringIfExists()

MaybeHandle< String > v8::internal::StringTable::LookupStringIfExists ( Isolate isolate,
Handle< String str 
)
static

Definition at line 14673 of file objects.cc.

14675  {
14676  Handle<StringTable> string_table = isolate->factory()->string_table();
14677  InternalizedStringKey key(string);
14678  int entry = string_table->FindEntry(&key);
14679  if (entry == kNotFound) {
14680  return MaybeHandle<String>();
14681  } else {
14682  Handle<String> result(String::cast(string_table->KeyAt(entry)), isolate);
14683  DCHECK(StringShape(*result).IsInternalized());
14684  return result;
14685  }
14686 }
#define DCHECK(condition)
Definition: logging.h:205

References DCHECK, and v8::internal::Isolate::factory().

+ Here is the call graph for this function:

◆ LookupTwoCharsStringIfExists()

MaybeHandle< String > v8::internal::StringTable::LookupTwoCharsStringIfExists ( Isolate isolate,
uint16_t  c1,
uint16_t  c2 
)
static

Definition at line 14689 of file objects.cc.

14692  {
14693  Handle<StringTable> string_table = isolate->factory()->string_table();
14694  TwoCharHashTableKey key(c1, c2, isolate->heap()->HashSeed());
14695  int entry = string_table->FindEntry(&key);
14696  if (entry == kNotFound) {
14697  return MaybeHandle<String>();
14698  } else {
14699  Handle<String> result(String::cast(string_table->KeyAt(entry)), isolate);
14700  DCHECK(StringShape(*result).IsInternalized());
14701  return result;
14702  }
14703 }

References DCHECK, v8::internal::Isolate::factory(), v8::internal::Heap::HashSeed(), and v8::internal::Isolate::heap().

Referenced by v8::internal::MakeOrFindTwoCharacterString().

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

Friends And Related Function Documentation

◆ JsonParser

template<bool seq_one_byte>
friend class JsonParser
friend

Definition at line 3440 of file objects.h.


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