V8 Project
v8::internal::PolymorphicCodeCacheHashTableKey Class Reference
+ Inheritance diagram for v8::internal::PolymorphicCodeCacheHashTableKey:
+ Collaboration diagram for v8::internal::PolymorphicCodeCacheHashTableKey:

Public Member Functions

 PolymorphicCodeCacheHashTableKey (MapHandleList *maps, int code_flags)
 
bool IsMatch (Object *other) OVERRIDE
 
uint32_t Hash () OVERRIDE
 
uint32_t HashForObject (Object *obj) OVERRIDE
 
MUST_USE_RESULT Handle< ObjectAsHandle (Isolate *isolate) OVERRIDE
 
- Public Member Functions inherited from v8::internal::HashTableKey
virtual ~HashTableKey ()
 

Static Public Member Functions

static uint32_t MapsHashHelper (MapHandleList *maps, int code_flags)
 

Static Private Member Functions

static MapHandleListFromObject (Object *obj, int *code_flags, MapHandleList *maps)
 

Private Attributes

MapHandleListmaps_
 
int code_flags_
 

Static Private Attributes

static const int kDefaultListAllocationSize = kMaxKeyedPolymorphism + 1
 

Detailed Description

Definition at line 7577 of file objects.cc.

Constructor & Destructor Documentation

◆ PolymorphicCodeCacheHashTableKey()

v8::internal::PolymorphicCodeCacheHashTableKey::PolymorphicCodeCacheHashTableKey ( MapHandleList maps,
int  code_flags 
)
inline

Definition at line 7580 of file objects.cc.

Member Function Documentation

◆ AsHandle()

MUST_USE_RESULT Handle<Object> v8::internal::PolymorphicCodeCacheHashTableKey::AsHandle ( Isolate isolate)
inlinevirtual

Implements v8::internal::HashTableKey.

Definition at line 7630 of file objects.cc.

7630  {
7631  // The maps in |maps_| must be copied to a newly allocated FixedArray,
7632  // both because the referenced MapList is short-lived, and because C++
7633  // objects can't be stored in the heap anyway.
7634  Handle<FixedArray> list =
7635  isolate->factory()->NewUninitializedFixedArray(maps_->length() + 1);
7636  list->set(0, Smi::FromInt(code_flags_));
7637  for (int i = 0; i < maps_->length(); ++i) {
7638  list->set(i + 1, *maps_->at(i));
7639  }
7640  return list;
7641  }
T & at(int i) const
Definition: list.h:69
static Smi * FromInt(int value)
Definition: objects-inl.h:1321

References v8::internal::Isolate::factory(), and v8::internal::Smi::FromInt().

Referenced by v8::internal::PolymorphicCodeCacheHashTable::Put().

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

◆ FromObject()

static MapHandleList* v8::internal::PolymorphicCodeCacheHashTableKey::FromObject ( Object obj,
int code_flags,
MapHandleList maps 
)
inlinestaticprivate

Definition at line 7644 of file objects.cc.

7646  {
7647  FixedArray* list = FixedArray::cast(obj);
7648  maps->Rewind(0);
7649  *code_flags = Smi::cast(list->get(0))->value();
7650  for (int i = 1; i < list->length(); ++i) {
7651  maps->Add(Handle<Map>(Map::cast(list->get(i))));
7652  }
7653  return maps;
7654  }

References v8::internal::List< T, AllocationPolicy >::Add(), v8::internal::FixedArray::get(), and v8::internal::FixedArrayBase::length().

+ Here is the call graph for this function:

◆ Hash()

uint32_t v8::internal::PolymorphicCodeCacheHashTableKey::Hash ( )
inlinevirtual

Implements v8::internal::HashTableKey.

Definition at line 7619 of file objects.cc.

7619  {
7620  return MapsHashHelper(maps_, code_flags_);
7621  }
static uint32_t MapsHashHelper(MapHandleList *maps, int code_flags)
Definition: objects.cc:7611

Referenced by v8::internal::PolymorphicCodeCacheHashTable::Put().

+ Here is the caller graph for this function:

◆ HashForObject()

uint32_t v8::internal::PolymorphicCodeCacheHashTableKey::HashForObject ( Object obj)
inlinevirtual

Implements v8::internal::HashTableKey.

Definition at line 7623 of file objects.cc.

7623  {
7625  int other_flags;
7626  FromObject(obj, &other_flags, &other_maps);
7627  return MapsHashHelper(&other_maps, other_flags);
7628  }
static MapHandleList * FromObject(Object *obj, int *code_flags, MapHandleList *maps)
Definition: objects.cc:7644
List< Handle< Map > > MapHandleList
Definition: list.h:197

◆ IsMatch()

bool v8::internal::PolymorphicCodeCacheHashTableKey::IsMatch ( Object other)
inlinevirtual

Implements v8::internal::HashTableKey.

Definition at line 7584 of file objects.cc.

7584  {
7586  int other_flags;
7587  FromObject(other, &other_flags, &other_maps);
7588  if (code_flags_ != other_flags) return false;
7589  if (maps_->length() != other_maps.length()) return false;
7590  // Compare just the hashes first because it's faster.
7591  int this_hash = MapsHashHelper(maps_, code_flags_);
7592  int other_hash = MapsHashHelper(&other_maps, other_flags);
7593  if (this_hash != other_hash) return false;
7594 
7595  // Full comparison: for each map in maps_, look for an equivalent map in
7596  // other_maps. This implementation is slow, but probably good enough for
7597  // now because the lists are short (<= 4 elements currently).
7598  for (int i = 0; i < maps_->length(); ++i) {
7599  bool match_found = false;
7600  for (int j = 0; j < other_maps.length(); ++j) {
7601  if (*(maps_->at(i)) == *(other_maps.at(j))) {
7602  match_found = true;
7603  break;
7604  }
7605  }
7606  if (!match_found) return false;
7607  }
7608  return true;
7609  }

References v8::internal::List< T, AllocationPolicy >::at().

+ Here is the call graph for this function:

◆ MapsHashHelper()

static uint32_t v8::internal::PolymorphicCodeCacheHashTableKey::MapsHashHelper ( MapHandleList maps,
int  code_flags 
)
inlinestatic

Definition at line 7611 of file objects.cc.

7611  {
7612  uint32_t hash = code_flags;
7613  for (int i = 0; i < maps->length(); ++i) {
7614  hash ^= maps->at(i)->Hash();
7615  }
7616  return hash;
7617  }

References v8::internal::List< T, AllocationPolicy >::at().

+ Here is the call graph for this function:

Member Data Documentation

◆ code_flags_

int v8::internal::PolymorphicCodeCacheHashTableKey::code_flags_
private

Definition at line 7657 of file objects.cc.

◆ kDefaultListAllocationSize

const int v8::internal::PolymorphicCodeCacheHashTableKey::kDefaultListAllocationSize = kMaxKeyedPolymorphism + 1
staticprivate

Definition at line 7658 of file objects.cc.

◆ maps_

MapHandleList* v8::internal::PolymorphicCodeCacheHashTableKey::maps_
private

Definition at line 7656 of file objects.cc.


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