V8 Project
v8::internal::StringsStorage Class Reference

#include <profile-generator.h>

+ Collaboration diagram for v8::internal::StringsStorage:

Public Member Functions

 StringsStorage (Heap *heap)
 
 ~StringsStorage ()
 
const char * GetCopy (const char *src)
 
const char * GetFormatted (const char *format,...)
 
const char * GetVFormatted (const char *format, va_list args)
 
const char * GetName (Name *name)
 
const char * GetName (int index)
 
const char * GetFunctionName (Name *name)
 
const char * GetFunctionName (const char *name)
 
size_t GetUsedMemorySize () const
 

Private Member Functions

const char * AddOrDisposeString (char *str, int len)
 
HashMap::Entry * GetEntry (const char *str, int len)
 
 DISALLOW_COPY_AND_ASSIGN (StringsStorage)
 

Static Private Member Functions

static bool StringsMatch (void *key1, void *key2)
 

Private Attributes

uint32_t hash_seed_
 
HashMap names_
 

Static Private Attributes

static const int kMaxNameSize = 1024
 

Detailed Description

Definition at line 19 of file profile-generator.h.

Constructor & Destructor Documentation

◆ StringsStorage()

v8::internal::StringsStorage::StringsStorage ( Heap heap)
explicit

Definition at line 27 of file profile-generator.cc.

28  : hash_seed_(heap->HashSeed()), names_(StringsMatch) {
29 }
static bool StringsMatch(void *key1, void *key2)

◆ ~StringsStorage()

v8::internal::StringsStorage::~StringsStorage ( )

Definition at line 32 of file profile-generator.cc.

32  {
33  for (HashMap::Entry* p = names_.Start();
34  p != NULL;
35  p = names_.Next(p)) {
36  DeleteArray(reinterpret_cast<const char*>(p->value));
37  }
38 }
Entry * Next(Entry *p) const
Definition: hashmap.h:226
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 enable alignment of csp to bytes on platforms which prefer the register to always be NULL
void DeleteArray(T *array)
Definition: allocation.h:68

References v8::internal::DeleteArray(), names_, v8::internal::TemplateHashMapImpl< AllocationPolicy >::Next(), NULL, and v8::internal::TemplateHashMapImpl< AllocationPolicy >::Start().

+ Here is the call graph for this function:

Member Function Documentation

◆ AddOrDisposeString()

const char * v8::internal::StringsStorage::AddOrDisposeString ( char *  str,
int  len 
)
private

Definition at line 64 of file profile-generator.cc.

64  {
65  HashMap::Entry* entry = GetEntry(str, len);
66  if (entry->value == NULL) {
67  // New entry added.
68  entry->key = str;
69  entry->value = str;
70  } else {
71  DeleteArray(str);
72  }
73  return reinterpret_cast<const char*>(entry->value);
74 }
HashMap::Entry * GetEntry(const char *str, int len)

References v8::internal::DeleteArray(), GetEntry(), and NULL.

Referenced by GetName(), and GetVFormatted().

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

◆ DISALLOW_COPY_AND_ASSIGN()

v8::internal::StringsStorage::DISALLOW_COPY_AND_ASSIGN ( StringsStorage  )
private

◆ GetCopy()

const char * v8::internal::StringsStorage::GetCopy ( const char *  src)

Definition at line 41 of file profile-generator.cc.

41  {
42  int len = static_cast<int>(strlen(src));
43  HashMap::Entry* entry = GetEntry(src, len);
44  if (entry->value == NULL) {
45  Vector<char> dst = Vector<char>::New(len + 1);
46  StrNCpy(dst, src, len);
47  dst[len] = '\0';
48  entry->key = dst.start();
49  entry->value = entry->key;
50  }
51  return reinterpret_cast<const char*>(entry->value);
52 }
static Vector< T > New(int length)
Definition: vector.h:27
void StrNCpy(Vector< char > dest, const char *src, size_t n)
Definition: utils.cc:119

References GetEntry(), v8::internal::Vector< T >::New(), NULL, v8::internal::Vector< T >::start(), and v8::internal::StrNCpy().

Referenced by v8::internal::BasicHeapEntriesAllocator::AllocateEntry(), v8::internal::NativeObjectsExplorer::FindOrAddGroupInfo(), GetFunctionName(), and GetVFormatted().

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

◆ GetEntry()

HashMap::Entry * v8::internal::StringsStorage::GetEntry ( const char *  str,
int  len 
)
private

Definition at line 129 of file profile-generator.cc.

129  {
131  return names_.Lookup(const_cast<char*>(str), hash, true);
132 }
static uint32_t HashSequentialString(const schar *chars, int length, uint32_t seed)
Definition: objects-inl.h:6563
Entry * Lookup(void *key, uint32_t hash, bool insert, AllocationPolicy allocator=AllocationPolicy())
Definition: hashmap.h:114

References hash_seed_, v8::internal::StringHasher::HashSequentialString(), v8::internal::TemplateHashMapImpl< AllocationPolicy >::Lookup(), and names_.

Referenced by AddOrDisposeString(), and GetCopy().

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

◆ GetFormatted()

const char * v8::internal::StringsStorage::GetFormatted ( const char *  format,
  ... 
)

Definition at line 55 of file profile-generator.cc.

55  {
56  va_list args;
57  va_start(args, format);
58  const char* result = GetVFormatted(format, args);
59  va_end(args);
60  return result;
61 }
const char * GetVFormatted(const char *format, va_list args)

References GetVFormatted().

Referenced by v8::internal::V8HeapExplorer::AddEntry(), v8::internal::BasicHeapEntriesAllocator::AllocateEntry(), v8::internal::V8HeapExplorer::ExtractClosureReferences(), v8::internal::V8HeapExplorer::ExtractSharedFunctionInfoReferences(), GetName(), v8::internal::V8HeapExplorer::SetPropertyReference(), v8::internal::V8HeapExplorer::SetWeakReference(), v8::internal::V8HeapExplorer::TagBuiltinCodeObject(), and v8::internal::V8HeapExplorer::TagCodeObject().

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

◆ GetFunctionName() [1/2]

const char * v8::internal::StringsStorage::GetFunctionName ( const char *  name)

Definition at line 114 of file profile-generator.cc.

114  {
115  return GetCopy(name);
116 }
const char * GetCopy(const char *src)
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 enable alignment of csp to bytes on platforms which prefer the register to always be expose gc extension under the specified name show built in functions in stack traces use random jit cookie to mask large constants minimum length for automatic enable preparsing CPU profiler sampling interval in microseconds trace out of bounds accesses to external arrays default size of stack region v8 is allowed to maximum length of function source code printed in a stack trace min size of a semi the new space consists of two semi spaces print one trace line following each garbage collection do not print trace line after scavenger collection print cumulative GC statistics in name

References GetCopy(), and name.

+ Here is the call graph for this function:

◆ GetFunctionName() [2/2]

const char * v8::internal::StringsStorage::GetFunctionName ( Name name)

Definition at line 109 of file profile-generator.cc.

109  {
110  return GetName(name);
111 }
const char * GetName(Name *name)

References GetName(), and name.

Referenced by v8::internal::AllocationTracker::AddFunctionInfo(), and v8::internal::CpuProfilesCollection::GetFunctionName().

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

◆ GetName() [1/2]

const char * v8::internal::StringsStorage::GetName ( int  index)

Definition at line 104 of file profile-generator.cc.

104  {
105  return GetFormatted("%d", index);
106 }
const char * GetFormatted(const char *format,...)

References GetFormatted().

+ Here is the call graph for this function:

◆ GetName() [2/2]

const char * v8::internal::StringsStorage::GetName ( Name name)

Definition at line 88 of file profile-generator.cc.

88  {
89  if (name->IsString()) {
90  String* str = String::cast(name);
91  int length = Min(kMaxNameSize, str->length());
92  int actual_length = 0;
93  SmartArrayPointer<char> data =
94  str->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL, 0, length,
95  &actual_length);
96  return AddOrDisposeString(data.Detach(), actual_length);
97  } else if (name->IsSymbol()) {
98  return "<symbol>";
99  }
100  return "";
101 }
const char * AddOrDisposeString(char *str, int len)
static LifetimePosition Min(LifetimePosition a, LifetimePosition b)
@ DISALLOW_NULLS
Definition: objects.h:8337
@ ROBUST_STRING_TRAVERSAL
Definition: objects.h:8338

References AddOrDisposeString(), v8::internal::SmartPointerBase< Deallocator, T >::Detach(), v8::internal::DISALLOW_NULLS, kMaxNameSize, v8::internal::String::length(), v8::internal::Min(), name, v8::internal::ROBUST_STRING_TRAVERSAL, and v8::internal::String::ToCString().

Referenced by v8::internal::V8HeapExplorer::AddEntry(), v8::internal::AllocationTracker::AddFunctionInfo(), v8::internal::V8HeapExplorer::ExtractSharedFunctionInfoReferences(), GetFunctionName(), v8::internal::CpuProfilesCollection::GetName(), v8::internal::V8HeapExplorer::SetContextReference(), v8::internal::V8HeapExplorer::SetInternalReference(), v8::internal::SnapshotFiller::SetNamedAutoIndexReference(), and v8::internal::V8HeapExplorer::SetPropertyReference().

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

◆ GetUsedMemorySize()

size_t v8::internal::StringsStorage::GetUsedMemorySize ( ) const

Definition at line 119 of file profile-generator.cc.

119  {
120  size_t size = sizeof(*this);
121  size += sizeof(HashMap::Entry) * names_.capacity();
122  for (HashMap::Entry* p = names_.Start(); p != NULL; p = names_.Next(p)) {
123  size += strlen(reinterpret_cast<const char*>(p->value)) + 1;
124  }
125  return size;
126 }
uint32_t capacity() const
Definition: hashmap.h:66
enable harmony numeric enable harmony object literal extensions Optimize object size

References v8::internal::TemplateHashMapImpl< AllocationPolicy >::capacity(), names_, v8::internal::TemplateHashMapImpl< AllocationPolicy >::Next(), NULL, size, and v8::internal::TemplateHashMapImpl< AllocationPolicy >::Start().

+ Here is the call graph for this function:

◆ GetVFormatted()

const char * v8::internal::StringsStorage::GetVFormatted ( const char *  format,
va_list  args 
)

Definition at line 77 of file profile-generator.cc.

77  {
78  Vector<char> str = Vector<char>::New(1024);
79  int len = VSNPrintF(str, format, args);
80  if (len == -1) {
81  DeleteArray(str.start());
82  return GetCopy(format);
83  }
84  return AddOrDisposeString(str.start(), len);
85 }
int VSNPrintF(Vector< char > str, const char *format, va_list args)
Definition: utils.cc:114

References AddOrDisposeString(), v8::internal::DeleteArray(), GetCopy(), v8::internal::Vector< T >::New(), v8::internal::Vector< T >::start(), and v8::internal::VSNPrintF().

Referenced by GetFormatted().

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

◆ StringsMatch()

bool v8::internal::StringsStorage::StringsMatch ( void *  key1,
void *  key2 
)
staticprivate

Definition at line 21 of file profile-generator.cc.

21  {
22  return strcmp(reinterpret_cast<char*>(key1),
23  reinterpret_cast<char*>(key2)) == 0;
24 }

Member Data Documentation

◆ hash_seed_

uint32_t v8::internal::StringsStorage::hash_seed_
private

Definition at line 40 of file profile-generator.h.

Referenced by GetEntry().

◆ kMaxNameSize

const int v8::internal::StringsStorage::kMaxNameSize = 1024
staticprivate

Definition at line 34 of file profile-generator.h.

Referenced by GetName().

◆ names_

HashMap v8::internal::StringsStorage::names_
private

Definition at line 41 of file profile-generator.h.

Referenced by GetEntry(), GetUsedMemorySize(), and ~StringsStorage().


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