V8 Project
v8::internal::KeyedLookupCache Class Reference

#include <heap.h>

+ Collaboration diagram for v8::internal::KeyedLookupCache:

Classes

struct  Key
 

Public Member Functions

int Lookup (Handle< Map > map, Handle< Name > name)
 
void Update (Handle< Map > map, Handle< Name > name, int field_offset)
 
void Clear ()
 
 STATIC_ASSERT ((kEntriesPerBucket &(kEntriesPerBucket - 1))==0)
 
 STATIC_ASSERT (kEntriesPerBucket==-kHashMask)
 

Static Public Attributes

static const int kLength = 256
 
static const int kCapacityMask = kLength - 1
 
static const int kMapHashShift = 5
 
static const int kHashMask = -4
 
static const int kEntriesPerBucket = 4
 
static const int kEntryLength = 2
 
static const int kMapIndex = 0
 
static const int kKeyIndex = 1
 
static const int kNotFound = -1
 

Private Member Functions

 KeyedLookupCache ()
 
Address keys_address ()
 
Address field_offsets_address ()
 
 DISALLOW_COPY_AND_ASSIGN (KeyedLookupCache)
 

Static Private Member Functions

static int Hash (Handle< Map > map, Handle< Name > name)
 

Private Attributes

Key keys_ [kLength]
 
int field_offsets_ [kLength]
 

Friends

class ExternalReference
 
class Isolate
 

Detailed Description

Definition at line 2241 of file heap.h.

Constructor & Destructor Documentation

◆ KeyedLookupCache()

v8::internal::KeyedLookupCache::KeyedLookupCache ( )
inlineprivate

Definition at line 2267 of file heap.h.

2267  {
2268  for (int i = 0; i < kLength; ++i) {
2269  keys_[i].map = NULL;
2270  keys_[i].name = NULL;
2272  }
2273  }
static const int kLength
Definition: heap.h:2252
static const int kNotFound
Definition: heap.h:2260
int field_offsets_[kLength]
Definition: heap.h:2291
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

References field_offsets_, keys_, kLength, kNotFound, v8::internal::KeyedLookupCache::Key::map, v8::internal::KeyedLookupCache::Key::name, and NULL.

Member Function Documentation

◆ Clear()

void v8::internal::KeyedLookupCache::Clear ( )

Definition at line 5962 of file heap.cc.

5962  {
5963  for (int index = 0; index < kLength; index++) keys_[index].map = NULL;
5964 }
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 map

References keys_, kLength, map, and NULL.

Referenced by v8::internal::Heap::CreateInitialObjects(), and v8::internal::Heap::MarkCompactPrologue().

+ Here is the caller graph for this function:

◆ DISALLOW_COPY_AND_ASSIGN()

v8::internal::KeyedLookupCache::DISALLOW_COPY_AND_ASSIGN ( KeyedLookupCache  )
private

◆ field_offsets_address()

Address v8::internal::KeyedLookupCache::field_offsets_address ( )
inlineprivate

Definition at line 2281 of file heap.h.

2281  {
2282  return reinterpret_cast<Address>(&field_offsets_);
2283  }
byte * Address
Definition: globals.h:101

References field_offsets_.

◆ Hash()

int v8::internal::KeyedLookupCache::Hash ( Handle< Map map,
Handle< Name name 
)
inlinestaticprivate

Definition at line 5897 of file heap.cc.

5897  {
5898  DisallowHeapAllocation no_gc;
5899  // Uses only lower 32 bits if pointers are larger.
5900  uintptr_t addr_hash =
5901  static_cast<uint32_t>(reinterpret_cast<uintptr_t>(*map)) >> kMapHashShift;
5902  return static_cast<uint32_t>((addr_hash ^ name->Hash()) & kCapacityMask);
5903 }
static const int kCapacityMask
Definition: heap.h:2253
static const int kMapHashShift
Definition: heap.h:2254
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
PerThreadAssertScopeDebugOnly< HEAP_ALLOCATION_ASSERT, false > DisallowHeapAllocation
Definition: assert-scope.h:110

References kCapacityMask, kMapHashShift, and name.

Referenced by Lookup(), and Update().

+ Here is the caller graph for this function:

◆ keys_address()

Address v8::internal::KeyedLookupCache::keys_address ( )
inlineprivate

Definition at line 2279 of file heap.h.

2279 { return reinterpret_cast<Address>(&keys_); }

References keys_.

◆ Lookup()

int v8::internal::KeyedLookupCache::Lookup ( Handle< Map map,
Handle< Name name 
)

Definition at line 5906 of file heap.cc.

5906  {
5907  DisallowHeapAllocation no_gc;
5908  int index = (Hash(map, name) & kHashMask);
5909  for (int i = 0; i < kEntriesPerBucket; i++) {
5910  Key& key = keys_[index + i];
5911  if ((key.map == *map) && key.name->Equals(*name)) {
5912  return field_offsets_[index + i];
5913  }
5914  }
5915  return kNotFound;
5916 }
static const int kHashMask
Definition: heap.h:2255
static const int kEntriesPerBucket
Definition: heap.h:2256
static int Hash(Handle< Map > map, Handle< Name > name)
Definition: heap.cc:5897

References v8::internal::Name::Equals(), field_offsets_, Hash(), kEntriesPerBucket, keys_, kHashMask, kNotFound, map, v8::internal::KeyedLookupCache::Key::map, name, and v8::internal::KeyedLookupCache::Key::name.

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

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

◆ STATIC_ASSERT() [1/2]

v8::internal::KeyedLookupCache::STATIC_ASSERT ( (kEntriesPerBucket &(kEntriesPerBucket - 1))  = =0)

◆ STATIC_ASSERT() [2/2]

v8::internal::KeyedLookupCache::STATIC_ASSERT ( kEntriesPerBucket  = =-kHashMask)

◆ Update()

void v8::internal::KeyedLookupCache::Update ( Handle< Map map,
Handle< Name name,
int  field_offset 
)

Definition at line 5919 of file heap.cc.

5920  {
5921  DisallowHeapAllocation no_gc;
5922  if (!name->IsUniqueName()) {
5924  name->GetIsolate(), Handle<String>::cast(name)).ToHandle(&name)) {
5925  return;
5926  }
5927  }
5928  // This cache is cleared only between mark compact passes, so we expect the
5929  // cache to only contain old space names.
5930  DCHECK(!map->GetIsolate()->heap()->InNewSpace(*name));
5931 
5932  int index = (Hash(map, name) & kHashMask);
5933  // After a GC there will be free slots, so we use them in order (this may
5934  // help to get the most frequently used one in position 0).
5935  for (int i = 0; i < kEntriesPerBucket; i++) {
5936  Key& key = keys_[index];
5937  Object* free_entry_indicator = NULL;
5938  if (key.map == free_entry_indicator) {
5939  key.map = *map;
5940  key.name = *name;
5941  field_offsets_[index + i] = field_offset;
5942  return;
5943  }
5944  }
5945  // No free entry found in this bucket, so we move them all down one and
5946  // put the new entry at position zero.
5947  for (int i = kEntriesPerBucket - 1; i > 0; i--) {
5948  Key& key = keys_[index + i];
5949  Key& key2 = keys_[index + i - 1];
5950  key = key2;
5951  field_offsets_[index + i] = field_offsets_[index + i - 1];
5952  }
5953 
5954  // Write the new first entry.
5955  Key& key = keys_[index];
5956  key.map = *map;
5957  key.name = *name;
5958  field_offsets_[index] = field_offset;
5959 }
static Handle< T > cast(Handle< S > that)
Definition: handles.h:116
static MUST_USE_RESULT MaybeHandle< String > InternalizeStringIfExists(Isolate *isolate, Handle< String > string)
Definition: objects.cc:14663
#define DCHECK(condition)
Definition: logging.h:205
kSerializedDataOffset Object
Definition: objects-inl.h:5322

References DCHECK, field_offsets_, Hash(), v8::internal::StringTable::InternalizeStringIfExists(), kEntriesPerBucket, keys_, kHashMask, map, v8::internal::KeyedLookupCache::Key::map, name, v8::internal::KeyedLookupCache::Key::name, and NULL.

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

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

Friends And Related Function Documentation

◆ ExternalReference

friend class ExternalReference
friend

Definition at line 2293 of file heap.h.

◆ Isolate

friend class Isolate
friend

Definition at line 2294 of file heap.h.

Member Data Documentation

◆ field_offsets_

int v8::internal::KeyedLookupCache::field_offsets_[kLength]
private

Definition at line 2291 of file heap.h.

Referenced by field_offsets_address(), KeyedLookupCache(), Lookup(), and Update().

◆ kCapacityMask

const int v8::internal::KeyedLookupCache::kCapacityMask = kLength - 1
static

Definition at line 2253 of file heap.h.

Referenced by Hash().

◆ kEntriesPerBucket

const int v8::internal::KeyedLookupCache::kEntriesPerBucket = 4
static

◆ kEntryLength

const int v8::internal::KeyedLookupCache::kEntryLength = 2
static

◆ keys_

Key v8::internal::KeyedLookupCache::keys_[kLength]
private

Definition at line 2290 of file heap.h.

Referenced by Clear(), KeyedLookupCache(), keys_address(), Lookup(), and Update().

◆ kHashMask

const int v8::internal::KeyedLookupCache::kHashMask = -4
static

Definition at line 2255 of file heap.h.

Referenced by Lookup(), and Update().

◆ kKeyIndex

const int v8::internal::KeyedLookupCache::kKeyIndex = 1
static

◆ kLength

const int v8::internal::KeyedLookupCache::kLength = 256
static

Definition at line 2252 of file heap.h.

Referenced by Clear(), and KeyedLookupCache().

◆ kMapHashShift

const int v8::internal::KeyedLookupCache::kMapHashShift = 5
static

Definition at line 2254 of file heap.h.

Referenced by Hash().

◆ kMapIndex

const int v8::internal::KeyedLookupCache::kMapIndex = 0
static

◆ kNotFound

const int v8::internal::KeyedLookupCache::kNotFound = -1
static

Definition at line 2260 of file heap.h.

Referenced by KeyedLookupCache(), and Lookup().


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