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(const char* type, Handle<Name> name); | 166 MaybeHandle<Object> ReferenceError(const char* type, 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 void set_raw_constant_pool(Address* constant_pool, Isolate* isolate); |
258 inline Address raw_constant_pool() const; | |
259 | 259 |
260 void FindTargetMaps() { | 260 void FindTargetMaps() { |
261 if (target_maps_set_) return; | 261 if (target_maps_set_) return; |
262 target_maps_set_ = true; | 262 target_maps_set_ = true; |
263 if (UseVector()) { | 263 if (UseVector()) { |
264 nexus()->ExtractMaps(&target_maps_); | 264 nexus()->ExtractMaps(&target_maps_); |
265 } else { | 265 } else { |
266 if (state_ == MONOMORPHIC) { | 266 if (state_ == MONOMORPHIC) { |
267 Map* map = target_->FindFirstMap(); | 267 Map* map = target_->FindFirstMap(); |
268 if (map != NULL) target_maps_.Add(handle(map)); | 268 if (map != NULL) target_maps_.Add(handle(map)); |
269 } else if (state_ != UNINITIALIZED && state_ != PREMONOMORPHIC) { | 269 } else if (state_ != UNINITIALIZED && state_ != PREMONOMORPHIC) { |
270 target_->FindAllMaps(&target_maps_); | 270 target_->FindAllMaps(&target_maps_); |
271 } | 271 } |
272 } | 272 } |
273 } | 273 } |
274 | 274 |
275 // Frame pointer for the frame that uses (calls) the IC. | 275 // Frame pointer for the frame that uses (calls) the IC. |
276 Address fp_; | 276 Address fp_; |
277 | 277 |
278 // All access to the program counter of an IC structure is indirect | 278 // All access to the program counter of an IC structure is indirect |
279 // to make the code GC safe. This feature is crucial since | 279 // to make the code GC safe. This feature is crucial since |
280 // GetProperty and SetProperty are called and they in turn might | 280 // GetProperty and SetProperty are called and they in turn might |
281 // invoke the garbage collector. | 281 // invoke the garbage collector. |
282 Address* pc_address_; | 282 Address* pc_address_; |
283 | 283 |
284 Isolate* isolate_; | 284 Isolate* isolate_; |
285 | 285 |
286 // The constant pool of the code which originally called the IC (which might | 286 // The constant pool of the code which originally called the IC (which might |
287 // be for the breakpointed copy of the original code). | 287 // be for the breakpointed copy of the original code). |
288 Handle<ConstantPoolArray> raw_constant_pool_; | 288 union { |
289 Address* raw_constant_pool_; | |
290 Handle<ConstantPoolArray> raw_constant_pool_handle_; | |
291 }; | |
rmcilroy
2015/04/08 12:38:55
let's not make this a union. I'm not sure that sto
MTBrandyberry
2015/05/07 20:38:32
This address is the stack slot holding the constan
| |
289 | 292 |
290 // The original code target that missed. | 293 // The original code target that missed. |
291 Handle<Code> target_; | 294 Handle<Code> target_; |
292 bool target_set_; | 295 bool target_set_; |
293 bool vector_set_; | 296 bool vector_set_; |
294 State old_state_; // For saving if we marked as prototype failure. | 297 State old_state_; // For saving if we marked as prototype failure. |
295 State state_; | 298 State state_; |
296 Code::Kind kind_; | 299 Code::Kind kind_; |
297 Handle<Map> receiver_map_; | 300 Handle<Map> receiver_map_; |
298 MaybeHandle<Code> maybe_handler_; | 301 MaybeHandle<Code> maybe_handler_; |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
429 CacheHolderFlag cache_holder) OVERRIDE; | 432 CacheHolderFlag cache_holder) OVERRIDE; |
430 | 433 |
431 private: | 434 private: |
432 virtual Handle<Code> pre_monomorphic_stub() const; | 435 virtual Handle<Code> pre_monomorphic_stub() const; |
433 static Handle<Code> pre_monomorphic_stub(Isolate* isolate, | 436 static Handle<Code> pre_monomorphic_stub(Isolate* isolate, |
434 ExtraICState extra_state); | 437 ExtraICState extra_state); |
435 | 438 |
436 Handle<Code> SimpleFieldLoad(FieldIndex index); | 439 Handle<Code> SimpleFieldLoad(FieldIndex index); |
437 | 440 |
438 static void Clear(Isolate* isolate, Address address, Code* target, | 441 static void Clear(Isolate* isolate, Address address, Code* target, |
439 ConstantPoolArray* constant_pool); | 442 Address constant_pool); |
440 | 443 |
441 friend class IC; | 444 friend class IC; |
442 }; | 445 }; |
443 | 446 |
444 | 447 |
445 class KeyedLoadIC : public LoadIC { | 448 class KeyedLoadIC : public LoadIC { |
446 public: | 449 public: |
447 // ExtraICState bits (building on IC) | 450 // ExtraICState bits (building on IC) |
448 class IcCheckTypeField : public BitField<IcCheckType, 1, 1> {}; | 451 class IcCheckTypeField : public BitField<IcCheckType, 1, 1> {}; |
449 | 452 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
493 | 496 |
494 protected: | 497 protected: |
495 // receiver is HeapObject because it could be a String or a JSObject | 498 // receiver is HeapObject because it could be a String or a JSObject |
496 Handle<Code> LoadElementStub(Handle<HeapObject> receiver); | 499 Handle<Code> LoadElementStub(Handle<HeapObject> receiver); |
497 virtual Handle<Code> pre_monomorphic_stub() const { | 500 virtual Handle<Code> pre_monomorphic_stub() const { |
498 return pre_monomorphic_stub(isolate()); | 501 return pre_monomorphic_stub(isolate()); |
499 } | 502 } |
500 | 503 |
501 private: | 504 private: |
502 static void Clear(Isolate* isolate, Address address, Code* target, | 505 static void Clear(Isolate* isolate, Address address, Code* target, |
503 ConstantPoolArray* constant_pool); | 506 Address constant_pool); |
504 | 507 |
505 friend class IC; | 508 friend class IC; |
506 }; | 509 }; |
507 | 510 |
508 | 511 |
509 class StoreIC : public IC { | 512 class StoreIC : public IC { |
510 public: | 513 public: |
511 STATIC_ASSERT(i::LANGUAGE_END == 3); | 514 STATIC_ASSERT(i::LANGUAGE_END == 3); |
512 class LanguageModeState : public BitField<LanguageMode, 1, 2> {}; | 515 class LanguageModeState : public BitField<LanguageMode, 1, 2> {}; |
513 static ExtraICState ComputeExtraICState(LanguageMode flag) { | 516 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, | 574 void UpdateCaches(LookupIterator* lookup, Handle<Object> value, |
572 JSReceiver::StoreFromKeyed store_mode); | 575 JSReceiver::StoreFromKeyed store_mode); |
573 virtual Handle<Code> CompileHandler(LookupIterator* lookup, | 576 virtual Handle<Code> CompileHandler(LookupIterator* lookup, |
574 Handle<Object> value, | 577 Handle<Object> value, |
575 CacheHolderFlag cache_holder) OVERRIDE; | 578 CacheHolderFlag cache_holder) OVERRIDE; |
576 | 579 |
577 private: | 580 private: |
578 inline void set_target(Code* code); | 581 inline void set_target(Code* code); |
579 | 582 |
580 static void Clear(Isolate* isolate, Address address, Code* target, | 583 static void Clear(Isolate* isolate, Address address, Code* target, |
581 ConstantPoolArray* constant_pool); | 584 Address constant_pool); |
582 | 585 |
583 friend class IC; | 586 friend class IC; |
584 }; | 587 }; |
585 | 588 |
586 | 589 |
587 enum KeyedStoreCheckMap { kDontCheckMap, kCheckMap }; | 590 enum KeyedStoreCheckMap { kDontCheckMap, kCheckMap }; |
588 | 591 |
589 | 592 |
590 enum KeyedStoreIncrementLength { kDontIncrementLength, kIncrementLength }; | 593 enum KeyedStoreIncrementLength { kDontIncrementLength, kIncrementLength }; |
591 | 594 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
658 | 661 |
659 private: | 662 private: |
660 inline void set_target(Code* code); | 663 inline void set_target(Code* code); |
661 | 664 |
662 // Stub accessors. | 665 // Stub accessors. |
663 Handle<Code> sloppy_arguments_stub() { | 666 Handle<Code> sloppy_arguments_stub() { |
664 return isolate()->builtins()->KeyedStoreIC_SloppyArguments(); | 667 return isolate()->builtins()->KeyedStoreIC_SloppyArguments(); |
665 } | 668 } |
666 | 669 |
667 static void Clear(Isolate* isolate, Address address, Code* target, | 670 static void Clear(Isolate* isolate, Address address, Code* target, |
668 ConstantPoolArray* constant_pool); | 671 Address constant_pool); |
669 | 672 |
670 KeyedAccessStoreMode GetStoreMode(Handle<JSObject> receiver, | 673 KeyedAccessStoreMode GetStoreMode(Handle<JSObject> receiver, |
671 Handle<Object> key, Handle<Object> value); | 674 Handle<Object> key, Handle<Object> value); |
672 | 675 |
673 Handle<Map> ComputeTransitionedMap(Handle<Map> map, | 676 Handle<Map> ComputeTransitionedMap(Handle<Map> map, |
674 KeyedAccessStoreMode store_mode); | 677 KeyedAccessStoreMode store_mode); |
675 | 678 |
676 friend class IC; | 679 friend class IC; |
677 }; | 680 }; |
678 | 681 |
(...skipping 27 matching lines...) Expand all Loading... | |
706 | 709 |
707 private: | 710 private: |
708 static bool HasInlinedSmiCode(Address address); | 711 static bool HasInlinedSmiCode(Address address); |
709 | 712 |
710 bool strict() const { return op_ == Token::EQ_STRICT; } | 713 bool strict() const { return op_ == Token::EQ_STRICT; } |
711 Condition GetCondition() const { return ComputeCondition(op_); } | 714 Condition GetCondition() const { return ComputeCondition(op_); } |
712 | 715 |
713 static Code* GetRawUninitialized(Isolate* isolate, Token::Value op); | 716 static Code* GetRawUninitialized(Isolate* isolate, Token::Value op); |
714 | 717 |
715 static void Clear(Isolate* isolate, Address address, Code* target, | 718 static void Clear(Isolate* isolate, Address address, Code* target, |
716 ConstantPoolArray* constant_pool); | 719 Address constant_pool); |
717 | 720 |
718 Token::Value op_; | 721 Token::Value op_; |
719 | 722 |
720 friend class IC; | 723 friend class IC; |
721 }; | 724 }; |
722 | 725 |
723 | 726 |
724 class CompareNilIC : public IC { | 727 class CompareNilIC : public IC { |
725 public: | 728 public: |
726 explicit CompareNilIC(Isolate* isolate) : IC(EXTRA_CALL_FRAME, isolate) {} | 729 explicit CompareNilIC(Isolate* isolate) : IC(EXTRA_CALL_FRAME, isolate) {} |
727 | 730 |
728 Handle<Object> CompareNil(Handle<Object> object); | 731 Handle<Object> CompareNil(Handle<Object> object); |
729 | 732 |
730 static Handle<Code> GetUninitialized(); | 733 static Handle<Code> GetUninitialized(); |
731 | 734 |
732 static void Clear(Address address, Code* target, | 735 static void Clear(Address address, Code* target, Address constant_pool); |
733 ConstantPoolArray* constant_pool); | |
734 | 736 |
735 static Handle<Object> DoCompareNilSlow(Isolate* isolate, NilValue nil, | 737 static Handle<Object> DoCompareNilSlow(Isolate* isolate, NilValue nil, |
736 Handle<Object> object); | 738 Handle<Object> object); |
737 }; | 739 }; |
738 | 740 |
739 | 741 |
740 class ToBooleanIC : public IC { | 742 class ToBooleanIC : public IC { |
741 public: | 743 public: |
742 explicit ToBooleanIC(Isolate* isolate) : IC(EXTRA_CALL_FRAME, isolate) {} | 744 explicit ToBooleanIC(Isolate* isolate) : IC(EXTRA_CALL_FRAME, isolate) {} |
743 | 745 |
(...skipping 21 matching lines...) Expand all Loading... | |
765 | 767 |
766 // Support functions for interceptor handlers. | 768 // Support functions for interceptor handlers. |
767 DECLARE_RUNTIME_FUNCTION(LoadPropertyWithInterceptorOnly); | 769 DECLARE_RUNTIME_FUNCTION(LoadPropertyWithInterceptorOnly); |
768 DECLARE_RUNTIME_FUNCTION(LoadPropertyWithInterceptor); | 770 DECLARE_RUNTIME_FUNCTION(LoadPropertyWithInterceptor); |
769 DECLARE_RUNTIME_FUNCTION(LoadElementWithInterceptor); | 771 DECLARE_RUNTIME_FUNCTION(LoadElementWithInterceptor); |
770 DECLARE_RUNTIME_FUNCTION(StorePropertyWithInterceptor); | 772 DECLARE_RUNTIME_FUNCTION(StorePropertyWithInterceptor); |
771 } | 773 } |
772 } // namespace v8::internal | 774 } // namespace v8::internal |
773 | 775 |
774 #endif // V8_IC_H_ | 776 #endif // V8_IC_H_ |
OLD | NEW |