| 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 #include "src/messages.h" | 10 #include "src/messages.h" |
| 11 | 11 |
| 12 namespace v8 { | 12 namespace v8 { |
| 13 namespace internal { | 13 namespace internal { |
| 14 | 14 |
| 15 | |
| 16 // IC_UTIL_LIST defines all utility functions called from generated | |
| 17 // inline caching code. The argument for the macro, ICU, is the function name. | |
| 18 #define IC_UTIL_LIST(ICU) \ | |
| 19 ICU(LoadIC_Miss) \ | |
| 20 ICU(KeyedLoadIC_Miss) \ | |
| 21 ICU(CallIC_Miss) \ | |
| 22 ICU(CallIC_Customization_Miss) \ | |
| 23 ICU(StoreIC_Miss) \ | |
| 24 ICU(StoreIC_Slow) \ | |
| 25 ICU(KeyedStoreIC_Miss) \ | |
| 26 ICU(KeyedStoreIC_Slow) \ | |
| 27 /* Utilities for IC stubs. */ \ | |
| 28 ICU(StoreCallbackProperty) \ | |
| 29 ICU(LoadPropertyWithInterceptorOnly) \ | |
| 30 ICU(LoadPropertyWithInterceptor) \ | |
| 31 ICU(LoadElementWithInterceptor) \ | |
| 32 ICU(StorePropertyWithInterceptor) \ | |
| 33 ICU(CompareIC_Miss) \ | |
| 34 ICU(BinaryOpIC_Miss) \ | |
| 35 ICU(CompareNilIC_Miss) \ | |
| 36 ICU(Unreachable) \ | |
| 37 ICU(ToBooleanIC_Miss) | |
| 38 // | 15 // |
| 39 // IC is the base class for LoadIC, StoreIC, KeyedLoadIC, and KeyedStoreIC. | 16 // IC is the base class for LoadIC, StoreIC, KeyedLoadIC, and KeyedStoreIC. |
| 40 // | 17 // |
| 41 class IC { | 18 class IC { |
| 42 public: | 19 public: |
| 43 // The ids for utility called from the generated code. | |
| 44 enum UtilityId { | |
| 45 #define CONST_NAME(name) k##name, | |
| 46 IC_UTIL_LIST(CONST_NAME) | |
| 47 #undef CONST_NAME | |
| 48 kUtilityCount | |
| 49 }; | |
| 50 | |
| 51 // Looks up the address of the named utility. | |
| 52 static Address AddressFromUtilityId(UtilityId id); | |
| 53 | |
| 54 // Alias the inline cache state type to make the IC code more readable. | 20 // Alias the inline cache state type to make the IC code more readable. |
| 55 typedef InlineCacheState State; | 21 typedef InlineCacheState State; |
| 56 | 22 |
| 57 // The IC code is either invoked with no extra frames on the stack | 23 // The IC code is either invoked with no extra frames on the stack |
| 58 // or with a single extra frame for supporting calls. | 24 // or with a single extra frame for supporting calls. |
| 59 enum FrameDepth { NO_EXTRA_FRAME = 0, EXTRA_CALL_FRAME = 1 }; | 25 enum FrameDepth { NO_EXTRA_FRAME = 0, EXTRA_CALL_FRAME = 1 }; |
| 60 | 26 |
| 61 // Construct the IC structure with the given number of extra | 27 // Construct the IC structure with the given number of extra |
| 62 // JavaScript frames on the stack. | 28 // JavaScript frames on the stack. |
| 63 IC(FrameDepth depth, Isolate* isolate, FeedbackNexus* nexus = NULL, | 29 IC(FrameDepth depth, Isolate* isolate, FeedbackNexus* nexus = NULL, |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 ExtraICState extra_ic_state_; | 267 ExtraICState extra_ic_state_; |
| 302 MapHandleList target_maps_; | 268 MapHandleList target_maps_; |
| 303 bool target_maps_set_; | 269 bool target_maps_set_; |
| 304 | 270 |
| 305 FeedbackNexus* nexus_; | 271 FeedbackNexus* nexus_; |
| 306 | 272 |
| 307 DISALLOW_IMPLICIT_CONSTRUCTORS(IC); | 273 DISALLOW_IMPLICIT_CONSTRUCTORS(IC); |
| 308 }; | 274 }; |
| 309 | 275 |
| 310 | 276 |
| 311 // An IC_Utility encapsulates IC::UtilityId. It exists mainly because you | |
| 312 // cannot make forward declarations to an enum. | |
| 313 class IC_Utility { | |
| 314 public: | |
| 315 explicit IC_Utility(IC::UtilityId id) | |
| 316 : address_(IC::AddressFromUtilityId(id)), id_(id) {} | |
| 317 | |
| 318 Address address() const { return address_; } | |
| 319 | |
| 320 IC::UtilityId id() const { return id_; } | |
| 321 | |
| 322 private: | |
| 323 Address address_; | |
| 324 IC::UtilityId id_; | |
| 325 }; | |
| 326 | |
| 327 | |
| 328 class CallIC : public IC { | 277 class CallIC : public IC { |
| 329 public: | 278 public: |
| 330 CallIC(Isolate* isolate, CallICNexus* nexus) | 279 CallIC(Isolate* isolate, CallICNexus* nexus) |
| 331 : IC(EXTRA_CALL_FRAME, isolate, nexus) { | 280 : IC(EXTRA_CALL_FRAME, isolate, nexus) { |
| 332 DCHECK(nexus != NULL); | 281 DCHECK(nexus != NULL); |
| 333 } | 282 } |
| 334 | 283 |
| 335 void PatchMegamorphic(Handle<Object> function); | 284 void PatchMegamorphic(Handle<Object> function); |
| 336 | 285 |
| 337 void HandleMiss(Handle<Object> function); | 286 void HandleMiss(Handle<Object> function); |
| (...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 731 explicit ToBooleanIC(Isolate* isolate) : IC(EXTRA_CALL_FRAME, isolate) {} | 680 explicit ToBooleanIC(Isolate* isolate) : IC(EXTRA_CALL_FRAME, isolate) {} |
| 732 | 681 |
| 733 Handle<Object> ToBoolean(Handle<Object> object); | 682 Handle<Object> ToBoolean(Handle<Object> object); |
| 734 }; | 683 }; |
| 735 | 684 |
| 736 | 685 |
| 737 // Helper for BinaryOpIC and CompareIC. | 686 // Helper for BinaryOpIC and CompareIC. |
| 738 enum InlinedSmiCheck { ENABLE_INLINED_SMI_CHECK, DISABLE_INLINED_SMI_CHECK }; | 687 enum InlinedSmiCheck { ENABLE_INLINED_SMI_CHECK, DISABLE_INLINED_SMI_CHECK }; |
| 739 void PatchInlinedSmiCode(Address address, InlinedSmiCheck check); | 688 void PatchInlinedSmiCode(Address address, InlinedSmiCheck check); |
| 740 | 689 |
| 741 DECLARE_RUNTIME_FUNCTION(KeyedLoadIC_MissFromStubFailure); | |
| 742 DECLARE_RUNTIME_FUNCTION(KeyedStoreIC_MissFromStubFailure); | |
| 743 DECLARE_RUNTIME_FUNCTION(UnaryOpIC_Miss); | |
| 744 DECLARE_RUNTIME_FUNCTION(StoreIC_MissFromStubFailure); | |
| 745 DECLARE_RUNTIME_FUNCTION(ElementsTransitionAndStoreIC_Miss); | |
| 746 DECLARE_RUNTIME_FUNCTION(BinaryOpIC_Miss); | |
| 747 DECLARE_RUNTIME_FUNCTION(BinaryOpIC_MissWithAllocationSite); | |
| 748 DECLARE_RUNTIME_FUNCTION(CompareNilIC_Miss); | |
| 749 DECLARE_RUNTIME_FUNCTION(ToBooleanIC_Miss); | |
| 750 DECLARE_RUNTIME_FUNCTION(LoadIC_MissFromStubFailure); | |
| 751 | |
| 752 // Support functions for callbacks handlers. | |
| 753 DECLARE_RUNTIME_FUNCTION(StoreCallbackProperty); | |
| 754 | |
| 755 // Support functions for interceptor handlers. | |
| 756 DECLARE_RUNTIME_FUNCTION(LoadPropertyWithInterceptorOnly); | |
| 757 DECLARE_RUNTIME_FUNCTION(LoadPropertyWithInterceptor); | |
| 758 DECLARE_RUNTIME_FUNCTION(LoadElementWithInterceptor); | |
| 759 DECLARE_RUNTIME_FUNCTION(StorePropertyWithInterceptor); | |
| 760 } | 690 } |
| 761 } // namespace v8::internal | 691 } // namespace v8::internal |
| 762 | 692 |
| 763 #endif // V8_IC_H_ | 693 #endif // V8_IC_H_ |
| OLD | NEW |