V8 Project
v8::internal::KeyedLoadIC Class Reference

#include <ic.h>

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

Public Member Functions

 KeyedLoadIC (FrameDepth depth, Isolate *isolate)
 
MUST_USE_RESULT MaybeHandle< ObjectLoad (Handle< Object > object, Handle< Object > key)
 
- Public Member Functions inherited from v8::internal::LoadIC
ContextualMode contextual_mode () const
 
 LoadIC (FrameDepth depth, Isolate *isolate)
 
bool IsUndeclaredGlobal (Handle< Object > receiver)
 
MUST_USE_RESULT MaybeHandle< ObjectLoad (Handle< Object > object, Handle< Name > name)
 
- Public Member Functions inherited from v8::internal::IC
 IC (FrameDepth depth, Isolate *isolate)
 
virtual ~IC ()
 
State state () const
 
Address address () const
 
void UpdateState (Handle< Object > receiver, Handle< Object > name)
 
bool IsNameCompatibleWithPrototypeFailure (Handle< Object > name)
 
void MarkPrototypeFailure (Handle< Object > name)
 

Static Public Member Functions

static void GenerateMiss (MacroAssembler *masm)
 
static void GenerateRuntimeGetProperty (MacroAssembler *masm)
 
static void GenerateInitialize (MacroAssembler *masm)
 
static void GeneratePreMonomorphic (MacroAssembler *masm)
 
static void GenerateGeneric (MacroAssembler *masm)
 
static void GenerateString (MacroAssembler *masm)
 
static Handle< Codegeneric_stub (Isolate *isolate)
 
static Handle< Codepre_monomorphic_stub (Isolate *isolate)
 
- Static Public Member Functions inherited from v8::internal::LoadIC
static ExtraICState ComputeExtraICState (ContextualMode contextual_mode)
 
static void GenerateInitialize (MacroAssembler *masm)
 
static void GeneratePreMonomorphic (MacroAssembler *masm)
 
static void GenerateMiss (MacroAssembler *masm)
 
static void GenerateNormal (MacroAssembler *masm)
 
static void GenerateRuntimeGetProperty (MacroAssembler *masm)
 
static Handle< Codeinitialize_stub (Isolate *isolate, ExtraICState extra_state)
 
- Static Public Member Functions inherited from v8::internal::IC
static Address AddressFromUtilityId (UtilityId id)
 
static void RegisterWeakMapDependency (Handle< Code > stub)
 
static void InvalidateMaps (Code *stub)
 
static void Clear (Isolate *isolate, Address address, ConstantPoolArray *constant_pool)
 
template<class TypeClass >
static JSFunctionGetRootConstructor (TypeClass *type, Context *native_context)
 
static Handle< MapGetHandlerCacheHolder (HeapType *type, bool receiver_is_holder, Isolate *isolate, CacheHolderFlag *flag)
 
static Handle< MapGetICCacheHolder (HeapType *type, Isolate *isolate, CacheHolderFlag *flag)
 
static bool IsCleared (Code *code)
 
static Handle< MapTypeToMap (HeapType *type, Isolate *isolate)
 
template<class T >
static T::TypeHandle MapToType (Handle< Map > map, typename T::Region *region)
 
static Handle< HeapTypeCurrentTypeOf (Handle< Object > object, Isolate *isolate)
 

Static Public Attributes

static const int kSlowCaseBitFieldMask
 

Protected Member Functions

Handle< CodeLoadElementStub (Handle< JSObject > receiver)
 
virtual Handle< Codepre_monomorphic_stub () const
 
- Protected Member Functions inherited from v8::internal::LoadIC
void set_target (Code *code)
 
Handle< Codeslow_stub () const
 
virtual Handle< Codemegamorphic_stub () OVERRIDE
 
void UpdateCaches (LookupIterator *lookup)
 
virtual Handle< CodeCompileHandler (LookupIterator *lookup, Handle< Object > unused, CacheHolderFlag cache_holder)
 
- Protected Member Functions inherited from v8::internal::IC
Handle< Codetarget () const
 
Address fp () const
 
Address pc () const
 
Isolateisolate () const
 
SharedFunctionInfoGetSharedFunctionInfo () const
 
CodeGetCode () const
 
CodeGetOriginalCode () const
 
void set_target (Code *code)
 
bool is_target_set ()
 
char TransitionMarkFromState (IC::State state)
 
void TraceIC (const char *type, Handle< Object > name)
 
void TraceIC (const char *type, Handle< Object > name, State old_state, State new_state)
 
MaybeHandle< ObjectTypeError (const char *type, Handle< Object > object, Handle< Object > key)
 
MaybeHandle< ObjectReferenceError (const char *type, Handle< Name > name)
 
Handle< CodeComputeHandler (LookupIterator *lookup, Handle< Object > value=Handle< Code >::null())
 
void UpdateMonomorphicIC (Handle< Code > handler, Handle< Name > name)
 
bool UpdatePolymorphicIC (Handle< Name > name, Handle< Code > code)
 
void UpdateMegamorphicCache (HeapType *type, Name *name, Code *code)
 
void CopyICToMegamorphicCache (Handle< Name > name)
 
bool IsTransitionOfMonomorphicTarget (Map *source_map, Map *target_map)
 
void PatchCache (Handle< Name > name, Handle< Code > code)
 
Code::Kind kind () const
 
Code::Kind handler_kind () const
 
bool TryRemoveInvalidPrototypeDependentStub (Handle< Object > receiver, Handle< String > name)
 
ExtraICState extra_ic_state () const
 
void set_extra_ic_state (ExtraICState state)
 
Handle< HeapTypereceiver_type ()
 
void update_receiver_type (Handle< Object > receiver)
 
void TargetMaps (MapHandleList *list)
 
void TargetTypes (TypeHandleList *list)
 
MapFirstTargetMap ()
 
void UpdateTarget ()
 

Private Member Functions

Handle< Codegeneric_stub () const
 
Handle< Codestring_stub ()
 

Static Private Member Functions

static void Clear (Isolate *isolate, Address address, Code *target, ConstantPoolArray *constant_pool)
 

Friends

class IC
 

Additional Inherited Members

- Public Types inherited from v8::internal::IC
enum  UtilityId { kUtilityCount }
 
enum  FrameDepth { NO_EXTRA_FRAME = 0 , EXTRA_CALL_FRAME = 1 }
 
typedef InlineCacheState State
 
- Static Protected Member Functions inherited from v8::internal::IC
static CodeGetTargetAtAddress (Address address, ConstantPoolArray *constant_pool)
 
static void SetTargetAtAddress (Address address, Code *target, ConstantPoolArray *constant_pool)
 
static void OnTypeFeedbackChanged (Isolate *isolate, Address address, State old_state, State new_state, bool target_remains_ic_stub)
 
static void PostPatching (Address address, Code *target, Code *old_target)
 

Detailed Description

Definition at line 398 of file ic.h.

Constructor & Destructor Documentation

◆ KeyedLoadIC()

v8::internal::KeyedLoadIC::KeyedLoadIC ( FrameDepth  depth,
Isolate isolate 
)
inlineexplicit

Definition at line 400 of file ic.h.

401  : LoadIC(depth, isolate) {
402  DCHECK(target()->is_keyed_load_stub());
403  }
Isolate * isolate() const
Definition: ic.h:136
Handle< Code > target() const
Definition: ic.h:132
LoadIC(FrameDepth depth, Isolate *isolate)
Definition: ic.h:332
#define DCHECK(condition)
Definition: logging.h:205

References DCHECK, and v8::internal::IC::target().

+ Here is the call graph for this function:

Member Function Documentation

◆ Clear()

void v8::internal::KeyedLoadIC::Clear ( Isolate isolate,
Address  address,
Code target,
ConstantPoolArray constant_pool 
)
staticprivate

Definition at line 511 of file ic.cc.

512  {
513  if (IsCleared(target)) return;
514  // Make sure to also clear the map used in inline fast cases. If we
515  // do not clear these maps, cached code can keep objects alive
516  // through the embedded maps.
518 }
static void SetTargetAtAddress(Address address, Code *target, ConstantPoolArray *constant_pool)
Definition: ic-inl.h:96
ConstantPoolArray * constant_pool() const
Definition: ic-inl.h:51
Address address() const
Definition: ic-inl.h:19
static bool IsCleared(Code *code)
Definition: ic.h:112
virtual Handle< Code > pre_monomorphic_stub() const
Definition: ic.h:430

References v8::internal::IC::address(), v8::internal::IC::constant_pool(), v8::internal::IC::IsCleared(), v8::internal::IC::isolate(), pre_monomorphic_stub(), v8::internal::IC::SetTargetAtAddress(), and v8::internal::IC::target().

Referenced by v8::internal::IC::Clear().

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

◆ GenerateGeneric()

static void v8::internal::KeyedLoadIC::GenerateGeneric ( MacroAssembler masm)
static

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

+ Here is the caller graph for this function:

◆ GenerateInitialize()

static void v8::internal::KeyedLoadIC::GenerateInitialize ( MacroAssembler masm)
inlinestatic

Definition at line 411 of file ic.h.

411 { GenerateMiss(masm); }
static void GenerateMiss(MacroAssembler *masm)

References v8::internal::LoadIC::GenerateMiss().

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

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

◆ GenerateMiss()

static void v8::internal::KeyedLoadIC::GenerateMiss ( MacroAssembler masm)
static

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

+ Here is the caller graph for this function:

◆ GeneratePreMonomorphic()

static void v8::internal::KeyedLoadIC::GeneratePreMonomorphic ( MacroAssembler masm)
inlinestatic

Definition at line 412 of file ic.h.

412  {
413  GenerateMiss(masm);
414  }

References v8::internal::LoadIC::GenerateMiss().

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

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

◆ GenerateRuntimeGetProperty()

static void v8::internal::KeyedLoadIC::GenerateRuntimeGetProperty ( MacroAssembler masm)
static

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

+ Here is the caller graph for this function:

◆ GenerateString()

static void v8::internal::KeyedLoadIC::GenerateString ( MacroAssembler masm)
static

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

+ Here is the caller graph for this function:

◆ generic_stub() [1/2]

Handle<Code> v8::internal::KeyedLoadIC::generic_stub ( ) const
inlineprivate

Definition at line 435 of file ic.h.

435 { return generic_stub(isolate()); }
Handle< Code > generic_stub() const
Definition: ic.h:435

References generic_stub(), and v8::internal::IC::isolate().

Referenced by generic_stub(), v8::internal::LoadIC::Load(), Load(), LoadElementStub(), and v8::internal::LoadIC::megamorphic_stub().

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

◆ generic_stub() [2/2]

Handle< Code > v8::internal::KeyedLoadIC::generic_stub ( Isolate isolate)
static

Definition at line 568 of file ic.cc.

568  {
569  if (FLAG_compiled_keyed_generic_loads) {
570  return KeyedLoadGenericStub(isolate).GetCode();
571  } else {
572  return isolate->builtins()->KeyedLoadIC_Generic();
573  }
574 }
Builtins * builtins()
Definition: isolate.h:947

References v8::internal::Isolate::builtins(), and v8::internal::IC::isolate().

+ Here is the call graph for this function:

◆ Load()

MaybeHandle< Object > v8::internal::KeyedLoadIC::Load ( Handle< Object object,
Handle< Object key 
)

Definition at line 1171 of file ic.cc.

1172  {
1173  if (MigrateDeprecated(object)) {
1174  Handle<Object> result;
1176  isolate(), result, Runtime::GetObjectProperty(isolate(), object, key),
1177  Object);
1178  return result;
1179  }
1180 
1181  Handle<Object> load_handle;
1182  Handle<Code> stub = generic_stub();
1183 
1184  // Check for non-string values that can be converted into an
1185  // internalized string directly or is representable as a smi.
1186  key = TryConvertKey(key, isolate());
1187 
1188  if (key->IsInternalizedString() || key->IsSymbol()) {
1189  ASSIGN_RETURN_ON_EXCEPTION(isolate(), load_handle,
1190  LoadIC::Load(object, Handle<Name>::cast(key)),
1191  Object);
1192  } else if (FLAG_use_ic && !object->IsAccessCheckNeeded()) {
1193  if (object->IsString() && key->IsNumber()) {
1194  if (state() == UNINITIALIZED) stub = string_stub();
1195  } else if (object->IsJSObject()) {
1196  Handle<JSObject> receiver = Handle<JSObject>::cast(object);
1197  if (!Object::ToSmi(isolate(), key).is_null()) {
1198  stub = LoadElementStub(receiver);
1199  }
1200  }
1201  }
1202 
1203  if (!is_target_set()) {
1204  Code* generic = *generic_stub();
1205  if (*stub == generic) {
1206  TRACE_GENERIC_IC(isolate(), "KeyedLoadIC", "set generic");
1207  }
1208  set_target(*stub);
1209  TRACE_IC("LoadIC", key);
1210  }
1211 
1212  if (!load_handle.is_null()) return load_handle;
1213  Handle<Object> result;
1215  Runtime::GetObjectProperty(isolate(), object, key),
1216  Object);
1217  return result;
1218 }
static Handle< T > cast(Handle< S > that)
Definition: handles.h:116
bool is_target_set()
Definition: ic.h:147
State state() const
Definition: ic.h:66
Handle< Code > LoadElementStub(Handle< JSObject > receiver)
Definition: ic.cc:1124
Handle< Code > string_stub()
Definition: ic.h:436
void set_target(Code *code)
Definition: ic-inl.h:130
MUST_USE_RESULT MaybeHandle< Object > Load(Handle< Object > object, Handle< Name > name)
Definition: ic.cc:586
static MUST_USE_RESULT MaybeHandle< Smi > ToSmi(Isolate *isolate, Handle< Object > object)
Definition: objects-inl.h:1081
static MUST_USE_RESULT MaybeHandle< Object > GetObjectProperty(Isolate *isolate, Handle< Object > object, Handle< Object > key)
Definition: runtime.cc:1912
#define TRACE_GENERIC_IC(isolate, type, reason)
Definition: ic.cc:79
#define TRACE_IC(type, name)
Definition: ic.cc:137
#define ASSIGN_RETURN_ON_EXCEPTION(isolate, dst, call, T)
Definition: isolate.h:135
kSerializedDataOffset Object
Definition: objects-inl.h:5322
static bool MigrateDeprecated(Handle< Object > object)
Definition: ic.cc:577
@ UNINITIALIZED
Definition: globals.h:446
static Handle< Object > TryConvertKey(Handle< Object > key, Isolate *isolate)
Definition: ic.cc:1104

References ASSIGN_RETURN_ON_EXCEPTION, v8::internal::Handle< T >::cast(), generic_stub(), v8::internal::Runtime::GetObjectProperty(), v8::internal::Handle< T >::is_null(), v8::internal::IC::is_target_set(), v8::internal::IC::isolate(), v8::internal::LoadIC::Load(), LoadElementStub(), v8::internal::MigrateDeprecated(), v8::internal::LoadIC::set_target(), v8::internal::IC::state(), string_stub(), v8::internal::Object::ToSmi(), TRACE_GENERIC_IC, TRACE_IC, v8::internal::TryConvertKey(), and v8::internal::UNINITIALIZED.

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

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

◆ LoadElementStub()

Handle< Code > v8::internal::KeyedLoadIC::LoadElementStub ( Handle< JSObject receiver)
protected

Definition at line 1124 of file ic.cc.

1124  {
1125  Handle<Map> receiver_map(receiver->map(), isolate());
1126  MapHandleList target_receiver_maps;
1127  if (target().is_identical_to(string_stub())) {
1128  target_receiver_maps.Add(isolate()->factory()->string_map());
1129  } else {
1130  TargetMaps(&target_receiver_maps);
1131  }
1132  if (target_receiver_maps.length() == 0) {
1134  }
1135 
1136  // The first time a receiver is seen that is a transitioned version of the
1137  // previous monomorphic receiver type, assume the new ElementsKind is the
1138  // monomorphic type. This benefits global arrays that only transition
1139  // once, and all call sites accessing them are faster if they remain
1140  // monomorphic. If this optimistic assumption is not true, the IC will
1141  // miss again and it will become polymorphic and support both the
1142  // untransitioned and transitioned maps.
1144  target_receiver_maps.at(0)->elements_kind(),
1145  receiver->GetElementsKind())) {
1147  }
1148 
1149  DCHECK(state() != GENERIC);
1150 
1151  // Determine the list of receiver maps that this call site has seen,
1152  // adding the map that was just encountered.
1153  if (!AddOneReceiverMapIfMissing(&target_receiver_maps, receiver_map)) {
1154  // If the miss wasn't due to an unseen map, a polymorphic stub
1155  // won't help, use the generic stub.
1156  TRACE_GENERIC_IC(isolate(), "KeyedLoadIC", "same map added twice");
1157  return generic_stub();
1158  }
1159 
1160  // If the maximum number of receiver maps has been exceeded, use the generic
1161  // version of the IC.
1162  if (target_receiver_maps.length() > kMaxKeyedPolymorphism) {
1163  TRACE_GENERIC_IC(isolate(), "KeyedLoadIC", "max polymorph exceeded");
1164  return generic_stub();
1165  }
1166 
1167  return PropertyICCompiler::ComputeKeyedLoadPolymorphic(&target_receiver_maps);
1168 }
void TargetMaps(MapHandleList *list)
Definition: ic.h:208
void Add(const T &element, AllocationPolicy allocator=AllocationPolicy())
Definition: list-inl.h:17
static Handle< Code > ComputeKeyedLoadMonomorphic(Handle< Map > receiver_map)
Definition: ic-compiler.cc:86
static Handle< Code > ComputeKeyedLoadPolymorphic(MapHandleList *receiver_maps)
Definition: ic-compiler.cc:244
bool IsMoreGeneralElementsKindTransition(ElementsKind from_kind, ElementsKind to_kind)
static bool AddOneReceiverMapIfMissing(MapHandleList *receiver_maps, Handle< Map > new_receiver_map)
Definition: ic.cc:635
const int kMaxKeyedPolymorphism
Definition: ic-state.h:14
List< Handle< Map > > MapHandleList
Definition: list.h:197

References v8::internal::List< T, AllocationPolicy >::Add(), v8::internal::AddOneReceiverMapIfMissing(), v8::internal::List< T, AllocationPolicy >::at(), v8::internal::PropertyICCompiler::ComputeKeyedLoadMonomorphic(), v8::internal::PropertyICCompiler::ComputeKeyedLoadPolymorphic(), DCHECK, v8::internal::GENERIC, generic_stub(), v8::internal::IsMoreGeneralElementsKindTransition(), v8::internal::IC::isolate(), v8::internal::kMaxKeyedPolymorphism, v8::internal::MONOMORPHIC, v8::internal::IC::state(), string_stub(), v8::internal::IC::target(), v8::internal::IC::TargetMaps(), and TRACE_GENERIC_IC.

Referenced by Load().

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

◆ pre_monomorphic_stub() [1/2]

virtual Handle<Code> v8::internal::KeyedLoadIC::pre_monomorphic_stub ( ) const
inlineprotectedvirtual

Reimplemented from v8::internal::LoadIC.

Definition at line 430 of file ic.h.

430  {
431  return pre_monomorphic_stub(isolate());
432  }

References v8::internal::IC::isolate(), and v8::internal::LoadIC::pre_monomorphic_stub().

Referenced by Clear(), and v8::internal::LoadIC::pre_monomorphic_stub().

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

◆ pre_monomorphic_stub() [2/2]

Handle< Code > v8::internal::KeyedLoadIC::pre_monomorphic_stub ( Isolate isolate)
static

Definition at line 838 of file ic.cc.

838  {
839  return isolate->builtins()->KeyedLoadIC_PreMonomorphic();
840 }

References v8::internal::Isolate::builtins(), and v8::internal::IC::isolate().

+ Here is the call graph for this function:

◆ string_stub()

Handle<Code> v8::internal::KeyedLoadIC::string_stub ( )
inlineprivate

Definition at line 436 of file ic.h.

436  {
437  return isolate()->builtins()->KeyedLoadIC_String();
438  }

References v8::internal::Isolate::builtins(), and v8::internal::IC::isolate().

Referenced by Load(), and LoadElementStub().

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

Friends And Related Function Documentation

◆ IC

friend class IC
friend

Definition at line 443 of file ic.h.

Member Data Documentation

◆ kSlowCaseBitFieldMask

const int v8::internal::KeyedLoadIC::kSlowCaseBitFieldMask
static
Initial value:
=
static const int kHasIndexedInterceptor
Definition: objects.h:6243
static const int kIsAccessCheckNeeded
Definition: objects.h:6246

Definition at line 422 of file ic.h.


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