V8 Project
v8::internal::CallIC Class Reference

#include <ic.h>

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

Public Member Functions

 CallIC (Isolate *isolate)
 
void PatchMegamorphic (Handle< Object > function, Handle< TypeFeedbackVector > vector, Handle< Smi > slot)
 
void HandleMiss (Handle< Object > receiver, Handle< Object > function, Handle< TypeFeedbackVector > vector, Handle< Smi > slot)
 
bool DoCustomHandler (Handle< Object > receiver, Handle< Object > function, Handle< TypeFeedbackVector > vector, Handle< Smi > slot, const CallICState &state)
 
- 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 Handle< Codeinitialize_stub (Isolate *isolate, int argc, CallICState::CallType call_type)
 
static void Clear (Isolate *isolate, Address address, Code *target, ConstantPoolArray *constant_pool)
 
- 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)
 

Private Member Functions

IC::State FeedbackToState (Handle< TypeFeedbackVector > vector, Handle< Smi > slot) const
 

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
 
- 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())
 
virtual Handle< CodeCompileHandler (LookupIterator *lookup, Handle< Object > value, CacheHolderFlag cache_holder)
 
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
 
virtual Handle< Codemegamorphic_stub ()
 
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 ()
 
- 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 294 of file ic.h.

Constructor & Destructor Documentation

◆ CallIC()

v8::internal::CallIC::CallIC ( Isolate isolate)
inlineexplicit

Definition at line 296 of file ic.h.

Isolate * isolate() const
Definition: ic.h:136
IC(FrameDepth depth, Isolate *isolate)
Definition: ic.cc:141
@ EXTRA_CALL_FRAME
Definition: ic.h:59

Member Function Documentation

◆ Clear()

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

Definition at line 521 of file ic.cc.

522  {
523  // Currently, CallIC doesn't have state changes.
524 }

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

+ Here is the caller graph for this function:

◆ DoCustomHandler()

bool v8::internal::CallIC::DoCustomHandler ( Handle< Object receiver,
Handle< Object function,
Handle< TypeFeedbackVector vector,
Handle< Smi slot,
const CallICState &  state 
)

Definition at line 1891 of file ic.cc.

1893  {
1894  DCHECK(FLAG_use_ic && function->IsJSFunction());
1895 
1896  // Are we the array function?
1897  Handle<JSFunction> array_function =
1898  Handle<JSFunction>(isolate()->native_context()->array_function());
1899  if (array_function.is_identical_to(Handle<JSFunction>::cast(function))) {
1900  // Alter the slot.
1901  IC::State old_state = FeedbackToState(vector, slot);
1902  Object* feedback = vector->get(slot->value());
1903  if (!feedback->IsAllocationSite()) {
1904  Handle<AllocationSite> new_site =
1905  isolate()->factory()->NewAllocationSite();
1906  vector->set(slot->value(), *new_site);
1907  }
1908 
1909  CallIC_ArrayStub stub(isolate(), state);
1910  set_target(*stub.GetCode());
1911  Handle<String> name;
1912  if (array_function->shared()->name()->IsString()) {
1913  name = Handle<String>(String::cast(array_function->shared()->name()),
1914  isolate());
1915  }
1916 
1917  IC::State new_state = FeedbackToState(vector, slot);
1918  OnTypeFeedbackChanged(isolate(), address(), old_state, new_state, true);
1919  TRACE_VECTOR_IC("CallIC (custom handler)", name, old_state, new_state);
1920  return true;
1921  }
1922  return false;
1923 }
IC::State FeedbackToState(Handle< TypeFeedbackVector > vector, Handle< Smi > slot) const
Definition: ic-inl.h:211
static Handle< T > cast(Handle< S > that)
Definition: handles.h:116
State state() const
Definition: ic.h:66
Address address() const
Definition: ic-inl.h:19
void set_target(Code *code)
Definition: ic-inl.h:121
InlineCacheState State
Definition: ic.h:55
static void OnTypeFeedbackChanged(Isolate *isolate, Address address, State old_state, State new_state, bool target_remains_ic_stub)
Definition: ic.cc:392
Factory * factory()
Definition: isolate.h:982
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
#define TRACE_VECTOR_IC(type, name, old_state, new_state)
Definition: ic.cc:138
#define DCHECK(condition)
Definition: logging.h:205
kSerializedDataOffset Object
Definition: objects-inl.h:5322

References v8::internal::IC::address(), DCHECK, v8::internal::Isolate::factory(), FeedbackToState(), v8::internal::IC::isolate(), name, v8::internal::IC::OnTypeFeedbackChanged(), v8::internal::IC::set_target(), v8::internal::IC::state(), and TRACE_VECTOR_IC.

Referenced by HandleMiss().

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

◆ FeedbackToState()

IC::State v8::internal::CallIC::FeedbackToState ( Handle< TypeFeedbackVector vector,
Handle< Smi slot 
) const
inlineprivate

Definition at line 211 of file ic-inl.h.

212  {
214  Object* feedback = vector->get(slot->value());
215 
216  if (feedback == *TypeFeedbackVector::MegamorphicSentinel(isolate())) {
217  state = GENERIC;
218  } else if (feedback->IsAllocationSite() || feedback->IsJSFunction()) {
219  state = MONOMORPHIC;
220  } else {
222  }
223 
224  return state;
225 }
static Handle< Object > UninitializedSentinel(Isolate *isolate)
static Handle< Object > MegamorphicSentinel(Isolate *isolate)
#define CHECK(condition)
Definition: logging.h:36
@ UNINITIALIZED
Definition: globals.h:446

References CHECK, v8::internal::GENERIC, v8::internal::IC::isolate(), v8::internal::TypeFeedbackVector::MegamorphicSentinel(), v8::internal::MONOMORPHIC, v8::internal::IC::state(), v8::internal::UNINITIALIZED, and v8::internal::TypeFeedbackVector::UninitializedSentinel().

Referenced by DoCustomHandler(), HandleMiss(), and PatchMegamorphic().

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

◆ HandleMiss()

void v8::internal::CallIC::HandleMiss ( Handle< Object receiver,
Handle< Object function,
Handle< TypeFeedbackVector vector,
Handle< Smi slot 
)

Definition at line 1953 of file ic.cc.

1954  {
1955  CallICState state(target()->extra_ic_state());
1956  IC::State old_state = FeedbackToState(vector, slot);
1957  Handle<Object> name = isolate()->factory()->empty_string();
1958  Object* feedback = vector->get(slot->value());
1959 
1960  // Hand-coded MISS handling is easier if CallIC slots don't contain smis.
1961  DCHECK(!feedback->IsSmi());
1962 
1963  if (feedback->IsJSFunction() || !function->IsJSFunction()) {
1964  // We are going generic.
1965  vector->set(slot->value(),
1968  } else {
1969  // The feedback is either uninitialized or an allocation site.
1970  // It might be an allocation site because if we re-compile the full code
1971  // to add deoptimization support, we call with the default call-ic, and
1972  // merely need to patch the target to match the feedback.
1973  // TODO(mvstanton): the better approach is to dispense with patching
1974  // altogether, which is in progress.
1976  feedback->IsAllocationSite());
1977 
1978  // Do we want to install a custom handler?
1979  if (FLAG_use_ic &&
1980  DoCustomHandler(receiver, function, vector, slot, state)) {
1981  return;
1982  }
1983 
1984  vector->set(slot->value(), *function);
1985  }
1986 
1987  if (function->IsJSFunction()) {
1988  Handle<JSFunction> js_function = Handle<JSFunction>::cast(function);
1989  name = handle(js_function->shared()->name(), isolate());
1990  }
1991 
1992  IC::State new_state = FeedbackToState(vector, slot);
1993  OnTypeFeedbackChanged(isolate(), address(), old_state, new_state, true);
1994  TRACE_VECTOR_IC("CallIC", name, old_state, new_state);
1995 }
bool DoCustomHandler(Handle< Object > receiver, Handle< Object > function, Handle< TypeFeedbackVector > vector, Handle< Smi > slot, const CallICState &state)
Definition: ic.cc:1891
ExtraICState extra_ic_state() const
Definition: ic.h:200
Handle< Code > target() const
Definition: ic.h:132
@ SKIP_WRITE_BARRIER
Definition: objects.h:235
Handle< T > handle(T *t, Isolate *isolate)
Definition: handles.h:146

References v8::internal::IC::address(), v8::internal::Handle< T >::cast(), DCHECK, DoCustomHandler(), v8::internal::IC::extra_ic_state(), v8::internal::Isolate::factory(), FeedbackToState(), v8::internal::handle(), v8::internal::IC::isolate(), v8::internal::TypeFeedbackVector::MegamorphicSentinel(), name, v8::internal::IC::OnTypeFeedbackChanged(), v8::internal::SKIP_WRITE_BARRIER, v8::internal::IC::state(), v8::internal::IC::target(), TRACE_VECTOR_IC, and v8::internal::TypeFeedbackVector::UninitializedSentinel().

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

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

◆ initialize_stub()

Handle< Code > v8::internal::CallIC::initialize_stub ( Isolate isolate,
int  argc,
CallICState::CallType  call_type 
)
static

Definition at line 1338 of file ic.cc.

1339  {
1340  CallICStub stub(isolate, CallICState(argc, call_type));
1341  Handle<Code> code = stub.GetCode();
1342  return code;
1343 }

References v8::internal::IC::isolate().

+ Here is the call graph for this function:

◆ PatchMegamorphic()

void v8::internal::CallIC::PatchMegamorphic ( Handle< Object function,
Handle< TypeFeedbackVector vector,
Handle< Smi slot 
)

Definition at line 1926 of file ic.cc.

1928  {
1929  CallICState state(target()->extra_ic_state());
1930  IC::State old_state = FeedbackToState(vector, slot);
1931 
1932  // We are going generic.
1933  vector->set(slot->value(),
1936 
1937  CallICStub stub(isolate(), state);
1938  Handle<Code> code = stub.GetCode();
1939  set_target(*code);
1940 
1941  Handle<Object> name = isolate()->factory()->empty_string();
1942  if (function->IsJSFunction()) {
1943  Handle<JSFunction> js_function = Handle<JSFunction>::cast(function);
1944  name = handle(js_function->shared()->name(), isolate());
1945  }
1946 
1947  IC::State new_state = FeedbackToState(vector, slot);
1948  OnTypeFeedbackChanged(isolate(), address(), old_state, new_state, true);
1949  TRACE_VECTOR_IC("CallIC", name, old_state, new_state);
1950 }

References v8::internal::IC::address(), v8::internal::Handle< T >::cast(), v8::internal::IC::extra_ic_state(), v8::internal::Isolate::factory(), FeedbackToState(), v8::internal::handle(), v8::internal::IC::isolate(), v8::internal::TypeFeedbackVector::MegamorphicSentinel(), name, v8::internal::IC::OnTypeFeedbackChanged(), v8::internal::IC::set_target(), v8::internal::SKIP_WRITE_BARRIER, v8::internal::IC::state(), v8::internal::IC::target(), and TRACE_VECTOR_IC.

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

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

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