10 #include "src/feedback-vector.h" 11 #include "src/heap/factory.h" 12 #include "src/ic/stub-cache.h" 13 #include "src/isolate.h" 14 #include "src/message-template.h" 15 #include "src/objects/map.h" 16 #include "src/objects/maybe-object.h" 17 #include "src/objects/smi.h" 28 typedef InlineCacheState State;
30 static constexpr
int kMaxKeyedPolymorphism = 4;
34 static constexpr
int kMaxPolymorphicMapCount = 4;
39 virtual ~
IC() =
default;
41 State state()
const {
return state_; }
49 DCHECK(RecomputeHandlerForName(name));
51 state_ = RECOMPUTE_HANDLER;
54 bool IsAnyLoad()
const {
55 return IsLoadIC() || IsLoadGlobalIC() || IsKeyedLoadIC();
57 bool IsAnyStore()
const {
58 return IsStoreIC() || IsStoreOwnIC() || IsStoreGlobalIC() ||
59 IsKeyedStoreIC() || IsStoreInArrayLiteralICKind(kind());
70 JSFunction* host_function,
const char* reason);
73 Address fp()
const {
return fp_; }
74 Address pc()
const {
return *pc_address_; }
76 void set_slow_stub_reason(
const char* reason) { slow_stub_reason_ = reason; }
78 Isolate* isolate()
const {
return isolate_; }
83 inline bool AddressIsDeoptimizedCode()
const;
84 inline static bool AddressIsDeoptimizedCode(
Isolate* isolate,
87 bool is_vector_set() {
return vector_set_; }
88 inline bool vector_needs_update();
91 bool ConfigureVectorState(IC::State new_state,
Handle<Object> key);
100 void ConfigureVectorState(
Handle<Name> name, MapHandles
const& maps,
101 MaybeObjectHandles* handlers);
103 char TransitionMarkFromState(IC::State state);
122 bool IsTransitionOfMonomorphicTarget(
Map source_map,
Map target_map);
125 FeedbackSlotKind kind()
const {
return kind_; }
126 bool IsGlobalIC()
const {
return IsLoadGlobalIC() || IsStoreGlobalIC(); }
127 bool IsLoadIC()
const {
return IsLoadICKind(kind_); }
128 bool IsLoadGlobalIC()
const {
return IsLoadGlobalICKind(kind_); }
129 bool IsKeyedLoadIC()
const {
return IsKeyedLoadICKind(kind_); }
130 bool IsStoreGlobalIC()
const {
return IsStoreGlobalICKind(kind_); }
131 bool IsStoreIC()
const {
return IsStoreICKind(kind_); }
132 bool IsStoreOwnIC()
const {
return IsStoreOwnICKind(kind_); }
133 bool IsKeyedStoreIC()
const {
return IsKeyedStoreICKind(kind_); }
134 bool is_keyed()
const {
135 return IsKeyedLoadIC() || IsKeyedStoreIC() ||
136 IsStoreInArrayLiteralICKind(kind_);
140 Handle<Map> receiver_map() {
return receiver_map_; }
143 void TargetMaps(MapHandles* list) {
146 list->push_back(map);
150 Map FirstTargetMap() {
152 return !target_maps_.empty() ? *target_maps_[0] :
Map();
155 State saved_state()
const {
156 return state() == RECOMPUTE_HANDLER ? old_state_ : state();
163 inline Address constant_pool()
const;
164 inline Address raw_constant_pool()
const;
166 void FindTargetMaps() {
167 if (target_maps_set_)
return;
168 target_maps_set_ =
true;
169 nexus()->ExtractMaps(&target_maps_);
183 Address* constant_pool_address_;
190 FeedbackSlotKind kind_;
194 MapHandles target_maps_;
195 bool target_maps_set_;
197 const char* slow_stub_reason_;
201 DISALLOW_IMPLICIT_CONSTRUCTORS(
IC);
208 :
IC(isolate, vector, slot) {
212 static bool ShouldThrowReferenceError(FeedbackSlotKind kind) {
213 return kind == FeedbackSlotKind::kLoadGlobalNotInsideTypeof;
216 bool ShouldThrowReferenceError()
const {
217 return ShouldThrowReferenceError(kind());
225 return BUILTIN_CODE(isolate(), LoadIC_Slow);
236 friend class NamedLoadHandlerCompiler;
243 :
LoadIC(isolate, vector, slot) {}
249 return BUILTIN_CODE(isolate(), LoadGlobalIC_Slow);
257 :
LoadIC(isolate, vector, slot) {}
265 KeyedAccessLoadMode load_mode);
271 KeyedAccessLoadMode load_mode);
273 void LoadElementPolymorphicHandlers(MapHandles* receiver_maps,
274 MaybeObjectHandles* handlers,
275 KeyedAccessLoadMode load_mode);
280 bool CanChangeToAllowOutOfBounds(
Handle<Map> receiver_map);
287 :
IC(isolate, vector, slot) {
288 DCHECK(IsAnyStore());
291 LanguageMode language_mode()
const {
return nexus()->GetLanguageMode(); }
295 StoreOrigin store_origin = StoreOrigin::kNamed);
298 StoreOrigin store_origin);
304 return BUILTIN_CODE(isolate(), KeyedStoreIC_Slow);
310 StoreOrigin store_origin);
322 :
StoreIC(isolate, vector, slot) {}
329 return BUILTIN_CODE(isolate(), StoreGlobalIC_Slow);
333 enum KeyedStoreCheckMap { kDontCheckMap, kCheckMap };
336 enum KeyedStoreIncrementLength { kDontIncrementLength, kIncrementLength };
341 KeyedAccessStoreMode GetKeyedAccessStoreMode() {
342 return nexus()->GetKeyedAccessStoreMode();
347 :
StoreIC(isolate, vector, slot) {}
355 KeyedAccessStoreMode store_mode,
356 bool receiver_was_cow);
359 return BUILTIN_CODE(isolate(), KeyedStoreIC_Slow);
364 KeyedAccessStoreMode store_mode);
367 KeyedAccessStoreMode store_mode);
369 void StoreElementPolymorphicHandlers(MapHandles* receiver_maps,
370 MaybeObjectHandles* handlers,
371 KeyedAccessStoreMode store_mode);
381 DCHECK(IsStoreInArrayLiteralICKind(kind()));
388 return BUILTIN_CODE(isolate(), StoreInArrayLiteralIC_Slow);
395 #endif // V8_IC_IC_H_