V8 Project
v8::internal::CodeCache Class Reference

#include <objects.h>

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

Public Member Functions

ObjectLookup (Name *name, Code::Flags flags)
 
int GetIndex (Object *name, Code *code)
 
void RemoveByIndex (Object *name, Code *code, int index)
 
- Public Member Functions inherited from v8::internal::Struct
void InitializeBody (int object_size)
 
- 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 Update (Handle< CodeCache > cache, Handle< Name > name, Handle< Code > code)
 
- 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 kDefaultCacheOffset = HeapObject::kHeaderSize
 
static const int kNormalTypeCacheOffset
 
static const int kSize = kNormalTypeCacheOffset + 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
 

Private Member Functions

ObjectLookupDefaultCache (Name *name, Code::Flags flags)
 
ObjectLookupNormalTypeCache (Name *name, Code::Flags flags)
 
 DISALLOW_IMPLICIT_CONSTRUCTORS (CodeCache)
 

Static Private Member Functions

static void UpdateDefaultCache (Handle< CodeCache > code_cache, Handle< Name > name, Handle< Code > code)
 
static void UpdateNormalTypeCache (Handle< CodeCache > code_cache, Handle< Name > name, Handle< Code > code)
 

Static Private Attributes

static const int kCodeCacheEntrySize = 2
 
static const int kCodeCacheEntryNameOffset = 0
 
static const int kCodeCacheEntryCodeOffset = 1
 

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

Detailed Description

Definition at line 7891 of file objects.h.

Member Function Documentation

◆ DISALLOW_IMPLICIT_CONSTRUCTORS()

v8::internal::CodeCache::DISALLOW_IMPLICIT_CONSTRUCTORS ( CodeCache  )
private

◆ GetIndex()

int v8::internal::CodeCache::GetIndex ( Object name,
Code code 
)

Definition at line 7409 of file objects.cc.

7409  {
7410  if (code->type() == Code::NORMAL) {
7411  if (normal_type_cache()->IsUndefined()) return -1;
7412  CodeCacheHashTable* cache = CodeCacheHashTable::cast(normal_type_cache());
7413  return cache->GetIndex(Name::cast(name), code->flags());
7414  }
7415 
7416  FixedArray* array = default_cache();
7417  int len = array->length();
7418  for (int i = 0; i < len; i += kCodeCacheEntrySize) {
7419  if (array->get(i + kCodeCacheEntryCodeOffset) == code) return i + 1;
7420  }
7421  return -1;
7422 }
static const int kCodeCacheEntryCodeOffset
Definition: objects.h:7936
static const int kCodeCacheEntrySize
Definition: objects.h:7934
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 v8::internal::Code::flags(), v8::internal::FixedArray::get(), v8::internal::CodeCacheHashTable::GetIndex(), v8::internal::FixedArrayBase::length(), name, v8::internal::Code::NORMAL, and v8::internal::Code::type().

+ Here is the call graph for this function:

◆ Lookup()

Object * v8::internal::CodeCache::Lookup ( Name name,
Code::Flags  flags 
)

Definition at line 7370 of file objects.cc.

7370  {
7372  if (result->IsCode()) {
7373  if (Code::cast(result)->flags() == flags) return result;
7374  return GetHeap()->undefined_value();
7375  }
7376  return LookupNormalTypeCache(name, flags);
7377 }
Object * LookupNormalTypeCache(Name *name, Code::Flags flags)
Definition: objects.cc:7399
Object * LookupDefaultCache(Name *name, Code::Flags flags)
Definition: objects.cc:7380
static Flags RemoveTypeFromFlags(Flags flags)
Definition: objects-inl.h:5006
Heap * GetHeap() const
Definition: objects-inl.h:1379
kSerializedDataOffset Object
Definition: objects-inl.h:5322

References v8::internal::anonymous_namespace{flags.cc}::flags, v8::internal::HeapObject::GetHeap(), name, and v8::internal::Code::RemoveTypeFromFlags().

+ Here is the call graph for this function:

◆ LookupDefaultCache()

Object * v8::internal::CodeCache::LookupDefaultCache ( Name name,
Code::Flags  flags 
)
private

Definition at line 7380 of file objects.cc.

7380  {
7381  FixedArray* cache = default_cache();
7382  int length = cache->length();
7383  for (int i = 0; i < length; i += kCodeCacheEntrySize) {
7384  Object* key = cache->get(i + kCodeCacheEntryNameOffset);
7385  // Skip deleted elements.
7386  if (key->IsNull()) continue;
7387  if (key->IsUndefined()) return key;
7388  if (name->Equals(Name::cast(key))) {
7389  Code* code = Code::cast(cache->get(i + kCodeCacheEntryCodeOffset));
7390  if (Code::RemoveTypeFromFlags(code->flags()) == flags) {
7391  return code;
7392  }
7393  }
7394  }
7395  return GetHeap()->undefined_value();
7396 }
static const int kCodeCacheEntryNameOffset
Definition: objects.h:7935

References v8::internal::Code::flags(), v8::internal::anonymous_namespace{flags.cc}::flags, v8::internal::FixedArray::get(), v8::internal::HeapObject::GetHeap(), v8::internal::FixedArrayBase::length(), name, and v8::internal::Code::RemoveTypeFromFlags().

+ Here is the call graph for this function:

◆ LookupNormalTypeCache()

Object * v8::internal::CodeCache::LookupNormalTypeCache ( Name name,
Code::Flags  flags 
)
private

Definition at line 7399 of file objects.cc.

7399  {
7400  if (!normal_type_cache()->IsUndefined()) {
7401  CodeCacheHashTable* cache = CodeCacheHashTable::cast(normal_type_cache());
7402  return cache->Lookup(name, flags);
7403  } else {
7404  return GetHeap()->undefined_value();
7405  }
7406 }

References v8::internal::anonymous_namespace{flags.cc}::flags, v8::internal::HeapObject::GetHeap(), v8::internal::CodeCacheHashTable::Lookup(), and name.

+ Here is the call graph for this function:

◆ RemoveByIndex()

void v8::internal::CodeCache::RemoveByIndex ( Object name,
Code code,
int  index 
)

Definition at line 7425 of file objects.cc.

7425  {
7426  if (code->type() == Code::NORMAL) {
7427  DCHECK(!normal_type_cache()->IsUndefined());
7428  CodeCacheHashTable* cache = CodeCacheHashTable::cast(normal_type_cache());
7429  DCHECK(cache->GetIndex(Name::cast(name), code->flags()) == index);
7430  cache->RemoveByIndex(index);
7431  } else {
7432  FixedArray* array = default_cache();
7433  DCHECK(array->length() >= index && array->get(index)->IsCode());
7434  // Use null instead of undefined for deleted elements to distinguish
7435  // deleted elements from unused elements. This distinction is used
7436  // when looking up in the cache and when updating the cache.
7438  array->set_null(index - 1); // Name.
7439  array->set_null(index); // Code.
7440  }
7441 }
#define DCHECK(condition)
Definition: logging.h:205
#define DCHECK_EQ(v1, v2)
Definition: logging.h:206

References DCHECK, DCHECK_EQ, v8::internal::Code::flags(), v8::internal::FixedArray::get(), v8::internal::CodeCacheHashTable::GetIndex(), v8::internal::FixedArrayBase::length(), name, v8::internal::Code::NORMAL, v8::internal::CodeCacheHashTable::RemoveByIndex(), v8::internal::FixedArray::set_null(), and v8::internal::Code::type().

+ Here is the call graph for this function:

◆ Update()

void v8::internal::CodeCache::Update ( Handle< CodeCache cache,
Handle< Name name,
Handle< Code code 
)
static

Definition at line 7280 of file objects.cc.

7281  {
7282  // The number of monomorphic stubs for normal load/store/call IC's can grow to
7283  // a large number and therefore they need to go into a hash table. They are
7284  // used to load global properties from cells.
7285  if (code->type() == Code::NORMAL) {
7286  // Make sure that a hash table is allocated for the normal load code cache.
7287  if (code_cache->normal_type_cache()->IsUndefined()) {
7288  Handle<Object> result =
7289  CodeCacheHashTable::New(code_cache->GetIsolate(),
7291  code_cache->set_normal_type_cache(*result);
7292  }
7293  UpdateNormalTypeCache(code_cache, name, code);
7294  } else {
7295  DCHECK(code_cache->default_cache()->IsFixedArray());
7296  UpdateDefaultCache(code_cache, name, code);
7297  }
7298 }
static const int kInitialSize
Definition: objects.h:7979
static void UpdateNormalTypeCache(Handle< CodeCache > code_cache, Handle< Name > name, Handle< Code > code)
Definition: objects.cc:7360
static void UpdateDefaultCache(Handle< CodeCache > code_cache, Handle< Name > name, Handle< Code > code)
Definition: objects.cc:7301
static MUST_USE_RESULT Handle< CodeCacheHashTable > New(Isolate *isolate, int at_least_space_for, MinimumCapacity capacity_option=USE_DEFAULT_MINIMUM_CAPACITY, PretenureFlag pretenure=NOT_TENURED)
Definition: objects.cc:13756

References DCHECK, v8::internal::CodeCacheHashTable::kInitialSize, name, v8::internal::HashTable< CodeCacheHashTable, CodeCacheHashTableShape, HashTableKey * >::New(), and v8::internal::Code::NORMAL.

Referenced by v8::internal::Map::UpdateCodeCache().

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

◆ UpdateDefaultCache()

void v8::internal::CodeCache::UpdateDefaultCache ( Handle< CodeCache code_cache,
Handle< Name name,
Handle< Code code 
)
staticprivate

Definition at line 7301 of file objects.cc.

7302  {
7303  // When updating the default code cache we disregard the type encoded in the
7304  // flags. This allows call constant stubs to overwrite call field
7305  // stubs, etc.
7306  Code::Flags flags = Code::RemoveTypeFromFlags(code->flags());
7307 
7308  // First check whether we can update existing code cache without
7309  // extending it.
7310  Handle<FixedArray> cache = handle(code_cache->default_cache());
7311  int length = cache->length();
7312  {
7313  DisallowHeapAllocation no_alloc;
7314  int deleted_index = -1;
7315  for (int i = 0; i < length; i += kCodeCacheEntrySize) {
7316  Object* key = cache->get(i);
7317  if (key->IsNull()) {
7318  if (deleted_index < 0) deleted_index = i;
7319  continue;
7320  }
7321  if (key->IsUndefined()) {
7322  if (deleted_index >= 0) i = deleted_index;
7323  cache->set(i + kCodeCacheEntryNameOffset, *name);
7324  cache->set(i + kCodeCacheEntryCodeOffset, *code);
7325  return;
7326  }
7327  if (name->Equals(Name::cast(key))) {
7328  Code::Flags found =
7329  Code::cast(cache->get(i + kCodeCacheEntryCodeOffset))->flags();
7330  if (Code::RemoveTypeFromFlags(found) == flags) {
7331  cache->set(i + kCodeCacheEntryCodeOffset, *code);
7332  return;
7333  }
7334  }
7335  }
7336 
7337  // Reached the end of the code cache. If there were deleted
7338  // elements, reuse the space for the first of them.
7339  if (deleted_index >= 0) {
7340  cache->set(deleted_index + kCodeCacheEntryNameOffset, *name);
7341  cache->set(deleted_index + kCodeCacheEntryCodeOffset, *code);
7342  return;
7343  }
7344  }
7345 
7346  // Extend the code cache with some new entries (at least one). Must be a
7347  // multiple of the entry size.
7348  int new_length = length + ((length >> 1)) + kCodeCacheEntrySize;
7349  new_length = new_length - new_length % kCodeCacheEntrySize;
7350  DCHECK((new_length % kCodeCacheEntrySize) == 0);
7351  cache = FixedArray::CopySize(cache, new_length);
7352 
7353  // Add the (name, code) pair to the new cache.
7354  cache->set(length + kCodeCacheEntryNameOffset, *name);
7355  cache->set(length + kCodeCacheEntryCodeOffset, *code);
7356  code_cache->set_default_cache(*cache);
7357 }
uint32_t Flags
Definition: objects.h:4929
static Handle< FixedArray > CopySize(Handle< FixedArray > array, int new_length, PretenureFlag pretenure=NOT_TENURED)
Definition: objects.cc:7749
PerThreadAssertScopeDebugOnly< HEAP_ALLOCATION_ASSERT, false > DisallowHeapAllocation
Definition: assert-scope.h:110
Handle< T > handle(T *t, Isolate *isolate)
Definition: handles.h:146

References v8::internal::FixedArray::CopySize(), DCHECK, v8::internal::anonymous_namespace{flags.cc}::flags, v8::internal::handle(), name, and v8::internal::Code::RemoveTypeFromFlags().

+ Here is the call graph for this function:

◆ UpdateNormalTypeCache()

void v8::internal::CodeCache::UpdateNormalTypeCache ( Handle< CodeCache code_cache,
Handle< Name name,
Handle< Code code 
)
staticprivate

Definition at line 7360 of file objects.cc.

7361  {
7362  // Adding a new entry can cause a new cache to be allocated.
7363  Handle<CodeCacheHashTable> cache(
7364  CodeCacheHashTable::cast(code_cache->normal_type_cache()));
7365  Handle<Object> new_cache = CodeCacheHashTable::Put(cache, name, code);
7366  code_cache->set_normal_type_cache(*new_cache);
7367 }
static Handle< CodeCacheHashTable > Put(Handle< CodeCacheHashTable > table, Handle< Name > name, Handle< Code > code)
Definition: objects.cc:7505

References name, and v8::internal::CodeCacheHashTable::Put().

+ Here is the call graph for this function:

Member Data Documentation

◆ kCodeCacheEntryCodeOffset

const int v8::internal::CodeCache::kCodeCacheEntryCodeOffset = 1
staticprivate

Definition at line 7936 of file objects.h.

◆ kCodeCacheEntryNameOffset

const int v8::internal::CodeCache::kCodeCacheEntryNameOffset = 0
staticprivate

Definition at line 7935 of file objects.h.

◆ kCodeCacheEntrySize

const int v8::internal::CodeCache::kCodeCacheEntrySize = 2
staticprivate

Definition at line 7934 of file objects.h.

◆ kDefaultCacheOffset

const int v8::internal::CodeCache::kDefaultCacheOffset = HeapObject::kHeaderSize
static

◆ kNormalTypeCacheOffset

const int v8::internal::CodeCache::kNormalTypeCacheOffset
static
Initial value:
=
static const int kDefaultCacheOffset
Definition: objects.h:7919
const int kPointerSize
Definition: globals.h:129

Definition at line 7920 of file objects.h.

Referenced by v8::internal::V8HeapExplorer::ExtractCodeCacheReferences().

◆ kSize

const int v8::internal::CodeCache::kSize = kNormalTypeCacheOffset + kPointerSize
static

Definition at line 7922 of file objects.h.


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