OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_IC_H_ | 5 #ifndef V8_IC_H_ |
6 #define V8_IC_H_ | 6 #define V8_IC_H_ |
7 | 7 |
8 #include "src/ic/ic-state.h" | 8 #include "src/ic/ic-state.h" |
9 #include "src/macro-assembler.h" | 9 #include "src/macro-assembler.h" |
10 | 10 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 void UpdateState(Handle<Object> receiver, Handle<Object> name); | 70 void UpdateState(Handle<Object> receiver, Handle<Object> name); |
71 | 71 |
72 bool IsNameCompatibleWithPrototypeFailure(Handle<Object> name); | 72 bool IsNameCompatibleWithPrototypeFailure(Handle<Object> name); |
73 void MarkPrototypeFailure(Handle<Object> name) { | 73 void MarkPrototypeFailure(Handle<Object> name) { |
74 DCHECK(IsNameCompatibleWithPrototypeFailure(name)); | 74 DCHECK(IsNameCompatibleWithPrototypeFailure(name)); |
75 old_state_ = state_; | 75 old_state_ = state_; |
76 state_ = PROTOTYPE_FAILURE; | 76 state_ = PROTOTYPE_FAILURE; |
77 } | 77 } |
78 | 78 |
79 // Clear the inline cache to initial state. | 79 // Clear the inline cache to initial state. |
80 static void Clear(Isolate* isolate, Address address, | 80 static void Clear(Isolate* isolate, Address address, Address constant_pool); |
81 ConstantPoolArray* constant_pool); | |
82 | 81 |
83 #ifdef DEBUG | 82 #ifdef DEBUG |
84 bool IsLoadStub() const { | 83 bool IsLoadStub() const { |
85 return target()->is_load_stub() || target()->is_keyed_load_stub(); | 84 return target()->is_load_stub() || target()->is_keyed_load_stub(); |
86 } | 85 } |
87 | 86 |
88 bool IsStoreStub() const { | 87 bool IsStoreStub() const { |
89 return target()->is_store_stub() || target()->is_keyed_store_stub(); | 88 return target()->is_store_stub() || target()->is_keyed_store_stub(); |
90 } | 89 } |
91 | 90 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 void TraceIC(const char* type, Handle<Object> name); | 160 void TraceIC(const char* type, Handle<Object> name); |
162 void TraceIC(const char* type, Handle<Object> name, State old_state, | 161 void TraceIC(const char* type, Handle<Object> name, State old_state, |
163 State new_state); | 162 State new_state); |
164 | 163 |
165 MaybeHandle<Object> TypeError(const char* type, Handle<Object> object, | 164 MaybeHandle<Object> TypeError(const char* type, Handle<Object> object, |
166 Handle<Object> key); | 165 Handle<Object> key); |
167 MaybeHandle<Object> ReferenceError(Handle<Name> name); | 166 MaybeHandle<Object> ReferenceError(Handle<Name> name); |
168 | 167 |
169 // Access the target code for the given IC address. | 168 // Access the target code for the given IC address. |
170 static inline Code* GetTargetAtAddress(Address address, | 169 static inline Code* GetTargetAtAddress(Address address, |
171 ConstantPoolArray* constant_pool); | 170 Address constant_pool); |
172 static inline void SetTargetAtAddress(Address address, Code* target, | 171 static inline void SetTargetAtAddress(Address address, Code* target, |
173 ConstantPoolArray* constant_pool); | 172 Address constant_pool); |
174 static void OnTypeFeedbackChanged(Isolate* isolate, Address address, | 173 static void OnTypeFeedbackChanged(Isolate* isolate, Address address, |
175 State old_state, State new_state, | 174 State old_state, State new_state, |
176 bool target_remains_ic_stub); | 175 bool target_remains_ic_stub); |
177 // As a vector-based IC, type feedback must be updated differently. | 176 // As a vector-based IC, type feedback must be updated differently. |
178 static void OnTypeFeedbackChanged(Isolate* isolate, Code* host, | 177 static void OnTypeFeedbackChanged(Isolate* isolate, Code* host, |
179 TypeFeedbackVector* vector, State old_state, | 178 TypeFeedbackVector* vector, State old_state, |
180 State new_state); | 179 State new_state); |
181 static void PostPatching(Address address, Code* target, Code* old_target); | 180 static void PostPatching(Address address, Code* target, Code* old_target); |
182 | 181 |
183 // Compute the handler either by compiling or by retrieving a cached version. | 182 // Compute the handler either by compiling or by retrieving a cached version. |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 template <class NexusClass> | 246 template <class NexusClass> |
248 NexusClass* casted_nexus() { | 247 NexusClass* casted_nexus() { |
249 return static_cast<NexusClass*>(nexus_); | 248 return static_cast<NexusClass*>(nexus_); |
250 } | 249 } |
251 FeedbackNexus* nexus() const { return nexus_; } | 250 FeedbackNexus* nexus() const { return nexus_; } |
252 | 251 |
253 inline Code* get_host(); | 252 inline Code* get_host(); |
254 | 253 |
255 private: | 254 private: |
256 inline Code* raw_target() const; | 255 inline Code* raw_target() const; |
257 inline ConstantPoolArray* constant_pool() const; | 256 inline Address constant_pool() const; |
258 inline ConstantPoolArray* raw_constant_pool() const; | 257 inline Address raw_constant_pool() const; |
259 | 258 |
260 void FindTargetMaps() { | 259 void FindTargetMaps() { |
261 if (target_maps_set_) return; | 260 if (target_maps_set_) return; |
262 target_maps_set_ = true; | 261 target_maps_set_ = true; |
263 if (UseVector()) { | 262 if (UseVector()) { |
264 nexus()->ExtractMaps(&target_maps_); | 263 nexus()->ExtractMaps(&target_maps_); |
265 } else { | 264 } else { |
266 if (state_ == MONOMORPHIC) { | 265 if (state_ == MONOMORPHIC) { |
267 Map* map = target_->FindFirstMap(); | 266 Map* map = target_->FindFirstMap(); |
268 if (map != NULL) target_maps_.Add(handle(map)); | 267 if (map != NULL) target_maps_.Add(handle(map)); |
269 } else if (state_ != UNINITIALIZED && state_ != PREMONOMORPHIC) { | 268 } else if (state_ != UNINITIALIZED && state_ != PREMONOMORPHIC) { |
270 target_->FindAllMaps(&target_maps_); | 269 target_->FindAllMaps(&target_maps_); |
271 } | 270 } |
272 } | 271 } |
273 } | 272 } |
274 | 273 |
275 // Frame pointer for the frame that uses (calls) the IC. | 274 // Frame pointer for the frame that uses (calls) the IC. |
276 Address fp_; | 275 Address fp_; |
277 | 276 |
278 // All access to the program counter of an IC structure is indirect | 277 // All access to the program counter and constant pool of an IC structure is |
279 // to make the code GC safe. This feature is crucial since | 278 // indirect to make the code GC safe. This feature is crucial since |
280 // GetProperty and SetProperty are called and they in turn might | 279 // GetProperty and SetProperty are called and they in turn might |
281 // invoke the garbage collector. | 280 // invoke the garbage collector. |
282 Address* pc_address_; | 281 Address* pc_address_; |
283 | 282 |
284 Isolate* isolate_; | |
285 | |
286 // The constant pool of the code which originally called the IC (which might | 283 // The constant pool of the code which originally called the IC (which might |
287 // be for the breakpointed copy of the original code). | 284 // be for the breakpointed copy of the original code). |
288 Handle<ConstantPoolArray> raw_constant_pool_; | 285 Address* constant_pool_address_; |
| 286 |
| 287 Isolate* isolate_; |
289 | 288 |
290 // The original code target that missed. | 289 // The original code target that missed. |
291 Handle<Code> target_; | 290 Handle<Code> target_; |
292 bool target_set_; | 291 bool target_set_; |
293 bool vector_set_; | 292 bool vector_set_; |
294 State old_state_; // For saving if we marked as prototype failure. | 293 State old_state_; // For saving if we marked as prototype failure. |
295 State state_; | 294 State state_; |
296 Code::Kind kind_; | 295 Code::Kind kind_; |
297 Handle<Map> receiver_map_; | 296 Handle<Map> receiver_map_; |
298 MaybeHandle<Code> maybe_handler_; | 297 MaybeHandle<Code> maybe_handler_; |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 CacheHolderFlag cache_holder) override; | 428 CacheHolderFlag cache_holder) override; |
430 | 429 |
431 private: | 430 private: |
432 virtual Handle<Code> pre_monomorphic_stub() const; | 431 virtual Handle<Code> pre_monomorphic_stub() const; |
433 static Handle<Code> pre_monomorphic_stub(Isolate* isolate, | 432 static Handle<Code> pre_monomorphic_stub(Isolate* isolate, |
434 ExtraICState extra_state); | 433 ExtraICState extra_state); |
435 | 434 |
436 Handle<Code> SimpleFieldLoad(FieldIndex index); | 435 Handle<Code> SimpleFieldLoad(FieldIndex index); |
437 | 436 |
438 static void Clear(Isolate* isolate, Address address, Code* target, | 437 static void Clear(Isolate* isolate, Address address, Code* target, |
439 ConstantPoolArray* constant_pool); | 438 Address constant_pool); |
440 | 439 |
441 friend class IC; | 440 friend class IC; |
442 }; | 441 }; |
443 | 442 |
444 | 443 |
445 class KeyedLoadIC : public LoadIC { | 444 class KeyedLoadIC : public LoadIC { |
446 public: | 445 public: |
447 // ExtraICState bits (building on IC) | 446 // ExtraICState bits (building on IC) |
448 class IcCheckTypeField : public BitField<IcCheckType, 1, 1> {}; | 447 class IcCheckTypeField : public BitField<IcCheckType, 1, 1> {}; |
449 | 448 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
493 | 492 |
494 protected: | 493 protected: |
495 // receiver is HeapObject because it could be a String or a JSObject | 494 // receiver is HeapObject because it could be a String or a JSObject |
496 Handle<Code> LoadElementStub(Handle<HeapObject> receiver); | 495 Handle<Code> LoadElementStub(Handle<HeapObject> receiver); |
497 virtual Handle<Code> pre_monomorphic_stub() const { | 496 virtual Handle<Code> pre_monomorphic_stub() const { |
498 return pre_monomorphic_stub(isolate()); | 497 return pre_monomorphic_stub(isolate()); |
499 } | 498 } |
500 | 499 |
501 private: | 500 private: |
502 static void Clear(Isolate* isolate, Address address, Code* target, | 501 static void Clear(Isolate* isolate, Address address, Code* target, |
503 ConstantPoolArray* constant_pool); | 502 Address constant_pool); |
504 | 503 |
505 friend class IC; | 504 friend class IC; |
506 }; | 505 }; |
507 | 506 |
508 | 507 |
509 class StoreIC : public IC { | 508 class StoreIC : public IC { |
510 public: | 509 public: |
511 STATIC_ASSERT(i::LANGUAGE_END == 3); | 510 STATIC_ASSERT(i::LANGUAGE_END == 3); |
512 class LanguageModeState : public BitField<LanguageMode, 1, 2> {}; | 511 class LanguageModeState : public BitField<LanguageMode, 1, 2> {}; |
513 static ExtraICState ComputeExtraICState(LanguageMode flag) { | 512 static ExtraICState ComputeExtraICState(LanguageMode flag) { |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
571 void UpdateCaches(LookupIterator* lookup, Handle<Object> value, | 570 void UpdateCaches(LookupIterator* lookup, Handle<Object> value, |
572 JSReceiver::StoreFromKeyed store_mode); | 571 JSReceiver::StoreFromKeyed store_mode); |
573 virtual Handle<Code> CompileHandler(LookupIterator* lookup, | 572 virtual Handle<Code> CompileHandler(LookupIterator* lookup, |
574 Handle<Object> value, | 573 Handle<Object> value, |
575 CacheHolderFlag cache_holder) override; | 574 CacheHolderFlag cache_holder) override; |
576 | 575 |
577 private: | 576 private: |
578 inline void set_target(Code* code); | 577 inline void set_target(Code* code); |
579 | 578 |
580 static void Clear(Isolate* isolate, Address address, Code* target, | 579 static void Clear(Isolate* isolate, Address address, Code* target, |
581 ConstantPoolArray* constant_pool); | 580 Address constant_pool); |
582 | 581 |
583 friend class IC; | 582 friend class IC; |
584 }; | 583 }; |
585 | 584 |
586 | 585 |
587 enum KeyedStoreCheckMap { kDontCheckMap, kCheckMap }; | 586 enum KeyedStoreCheckMap { kDontCheckMap, kCheckMap }; |
588 | 587 |
589 | 588 |
590 enum KeyedStoreIncrementLength { kDontIncrementLength, kIncrementLength }; | 589 enum KeyedStoreIncrementLength { kDontIncrementLength, kIncrementLength }; |
591 | 590 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
658 | 657 |
659 private: | 658 private: |
660 inline void set_target(Code* code); | 659 inline void set_target(Code* code); |
661 | 660 |
662 // Stub accessors. | 661 // Stub accessors. |
663 Handle<Code> sloppy_arguments_stub() { | 662 Handle<Code> sloppy_arguments_stub() { |
664 return isolate()->builtins()->KeyedStoreIC_SloppyArguments(); | 663 return isolate()->builtins()->KeyedStoreIC_SloppyArguments(); |
665 } | 664 } |
666 | 665 |
667 static void Clear(Isolate* isolate, Address address, Code* target, | 666 static void Clear(Isolate* isolate, Address address, Code* target, |
668 ConstantPoolArray* constant_pool); | 667 Address constant_pool); |
669 | 668 |
670 KeyedAccessStoreMode GetStoreMode(Handle<JSObject> receiver, | 669 KeyedAccessStoreMode GetStoreMode(Handle<JSObject> receiver, |
671 Handle<Object> key, Handle<Object> value); | 670 Handle<Object> key, Handle<Object> value); |
672 | 671 |
673 Handle<Map> ComputeTransitionedMap(Handle<Map> map, | 672 Handle<Map> ComputeTransitionedMap(Handle<Map> map, |
674 KeyedAccessStoreMode store_mode); | 673 KeyedAccessStoreMode store_mode); |
675 | 674 |
676 friend class IC; | 675 friend class IC; |
677 }; | 676 }; |
678 | 677 |
(...skipping 28 matching lines...) Expand all Loading... |
707 | 706 |
708 private: | 707 private: |
709 static bool HasInlinedSmiCode(Address address); | 708 static bool HasInlinedSmiCode(Address address); |
710 | 709 |
711 bool strict() const { return op_ == Token::EQ_STRICT; } | 710 bool strict() const { return op_ == Token::EQ_STRICT; } |
712 Condition GetCondition() const { return ComputeCondition(op_); } | 711 Condition GetCondition() const { return ComputeCondition(op_); } |
713 | 712 |
714 static Code* GetRawUninitialized(Isolate* isolate, Token::Value op); | 713 static Code* GetRawUninitialized(Isolate* isolate, Token::Value op); |
715 | 714 |
716 static void Clear(Isolate* isolate, Address address, Code* target, | 715 static void Clear(Isolate* isolate, Address address, Code* target, |
717 ConstantPoolArray* constant_pool); | 716 Address constant_pool); |
718 | 717 |
719 Token::Value op_; | 718 Token::Value op_; |
720 | 719 |
721 friend class IC; | 720 friend class IC; |
722 }; | 721 }; |
723 | 722 |
724 | 723 |
725 class CompareNilIC : public IC { | 724 class CompareNilIC : public IC { |
726 public: | 725 public: |
727 explicit CompareNilIC(Isolate* isolate) : IC(EXTRA_CALL_FRAME, isolate) {} | 726 explicit CompareNilIC(Isolate* isolate) : IC(EXTRA_CALL_FRAME, isolate) {} |
728 | 727 |
729 Handle<Object> CompareNil(Handle<Object> object); | 728 Handle<Object> CompareNil(Handle<Object> object); |
730 | 729 |
731 static Handle<Code> GetUninitialized(); | 730 static Handle<Code> GetUninitialized(); |
732 | 731 |
733 static void Clear(Address address, Code* target, | 732 static void Clear(Address address, Code* target, Address constant_pool); |
734 ConstantPoolArray* constant_pool); | |
735 | 733 |
736 static Handle<Object> DoCompareNilSlow(Isolate* isolate, NilValue nil, | 734 static Handle<Object> DoCompareNilSlow(Isolate* isolate, NilValue nil, |
737 Handle<Object> object); | 735 Handle<Object> object); |
738 }; | 736 }; |
739 | 737 |
740 | 738 |
741 class ToBooleanIC : public IC { | 739 class ToBooleanIC : public IC { |
742 public: | 740 public: |
743 explicit ToBooleanIC(Isolate* isolate) : IC(EXTRA_CALL_FRAME, isolate) {} | 741 explicit ToBooleanIC(Isolate* isolate) : IC(EXTRA_CALL_FRAME, isolate) {} |
744 | 742 |
(...skipping 21 matching lines...) Expand all Loading... |
766 | 764 |
767 // Support functions for interceptor handlers. | 765 // Support functions for interceptor handlers. |
768 DECLARE_RUNTIME_FUNCTION(LoadPropertyWithInterceptorOnly); | 766 DECLARE_RUNTIME_FUNCTION(LoadPropertyWithInterceptorOnly); |
769 DECLARE_RUNTIME_FUNCTION(LoadPropertyWithInterceptor); | 767 DECLARE_RUNTIME_FUNCTION(LoadPropertyWithInterceptor); |
770 DECLARE_RUNTIME_FUNCTION(LoadElementWithInterceptor); | 768 DECLARE_RUNTIME_FUNCTION(LoadElementWithInterceptor); |
771 DECLARE_RUNTIME_FUNCTION(StorePropertyWithInterceptor); | 769 DECLARE_RUNTIME_FUNCTION(StorePropertyWithInterceptor); |
772 } | 770 } |
773 } // namespace v8::internal | 771 } // namespace v8::internal |
774 | 772 |
775 #endif // V8_IC_H_ | 773 #endif // V8_IC_H_ |
OLD | NEW |