| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 enum FrameDepth { | 87 enum FrameDepth { |
| 88 NO_EXTRA_FRAME = 0, | 88 NO_EXTRA_FRAME = 0, |
| 89 EXTRA_CALL_FRAME = 1 | 89 EXTRA_CALL_FRAME = 1 |
| 90 }; | 90 }; |
| 91 | 91 |
| 92 // Construct the IC structure with the given number of extra | 92 // Construct the IC structure with the given number of extra |
| 93 // JavaScript frames on the stack. | 93 // JavaScript frames on the stack. |
| 94 IC(FrameDepth depth, Isolate* isolate); | 94 IC(FrameDepth depth, Isolate* isolate); |
| 95 virtual ~IC() {} | 95 virtual ~IC() {} |
| 96 | 96 |
| 97 // Get the call-site target; used for determining the state. | |
| 98 Handle<Code> target() const { return target_; } | |
| 99 Code* raw_target() const { return GetTargetAtAddress(address()); } | |
| 100 | |
| 101 State state() const { return state_; } | 97 State state() const { return state_; } |
| 102 inline Address address() const; | 98 inline Address address() const; |
| 103 | 99 |
| 104 // Compute the current IC state based on the target stub, receiver and name. | 100 // Compute the current IC state based on the target stub, receiver and name. |
| 105 void UpdateState(Handle<Object> receiver, Handle<Object> name); | 101 void UpdateState(Handle<Object> receiver, Handle<Object> name); |
| 106 void MarkMonomorphicPrototypeFailure() { | 102 void MarkMonomorphicPrototypeFailure() { |
| 107 state_ = MONOMORPHIC_PROTOTYPE_FAILURE; | 103 state_ = MONOMORPHIC_PROTOTYPE_FAILURE; |
| 108 } | 104 } |
| 109 | 105 |
| 110 // Clear the inline cache to initial state. | 106 // Clear the inline cache to initial state. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 123 } else { | 119 } else { |
| 124 ASSERT(!SlowIsUndeclaredGlobal()); | 120 ASSERT(!SlowIsUndeclaredGlobal()); |
| 125 return false; | 121 return false; |
| 126 } | 122 } |
| 127 } | 123 } |
| 128 | 124 |
| 129 bool SlowIsUndeclaredGlobal() { | 125 bool SlowIsUndeclaredGlobal() { |
| 130 return ComputeMode() == RelocInfo::CODE_TARGET_CONTEXT; | 126 return ComputeMode() == RelocInfo::CODE_TARGET_CONTEXT; |
| 131 } | 127 } |
| 132 | 128 |
| 129 #ifdef DEBUG |
| 130 bool IsLoadStub() { |
| 131 return target()->is_load_stub() || target()->is_keyed_load_stub(); |
| 132 } |
| 133 |
| 134 bool IsStoreStub() { |
| 135 return target()->is_store_stub() || target()->is_keyed_store_stub(); |
| 136 } |
| 137 |
| 138 bool IsCallStub() { |
| 139 return target()->is_call_stub() || target()->is_keyed_call_stub(); |
| 140 } |
| 141 #endif |
| 142 |
| 133 // Determines which map must be used for keeping the code stub. | 143 // Determines which map must be used for keeping the code stub. |
| 134 // These methods should not be called with undefined or null. | 144 // These methods should not be called with undefined or null. |
| 135 static inline InlineCacheHolderFlag GetCodeCacheForObject(Object* object, | 145 static inline InlineCacheHolderFlag GetCodeCacheForObject(Object* object, |
| 136 JSObject* holder); | 146 JSObject* holder); |
| 137 static inline JSObject* GetCodeCacheHolder(Isolate* isolate, | 147 static inline JSObject* GetCodeCacheHolder(Isolate* isolate, |
| 138 Object* object, | 148 Object* object, |
| 139 InlineCacheHolderFlag holder); | 149 InlineCacheHolderFlag holder); |
| 140 | 150 |
| 141 static bool IsCleared(Code* code) { | 151 static bool IsCleared(Code* code) { |
| 142 InlineCacheState state = code->ic_state(); | 152 InlineCacheState state = code->ic_state(); |
| 143 return state == UNINITIALIZED || state == PREMONOMORPHIC; | 153 return state == UNINITIALIZED || state == PREMONOMORPHIC; |
| 144 } | 154 } |
| 145 | 155 |
| 146 protected: | 156 protected: |
| 157 // Get the call-site target; used for determining the state. |
| 158 Handle<Code> target() const { return target_; } |
| 159 |
| 147 Address fp() const { return fp_; } | 160 Address fp() const { return fp_; } |
| 148 Address pc() const { return *pc_address_; } | 161 Address pc() const { return *pc_address_; } |
| 149 Isolate* isolate() const { return isolate_; } | 162 Isolate* isolate() const { return isolate_; } |
| 150 | 163 |
| 151 #ifdef ENABLE_DEBUGGER_SUPPORT | 164 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 152 // Computes the address in the original code when the code running is | 165 // Computes the address in the original code when the code running is |
| 153 // containing break points (calls to DebugBreakXXX builtins). | 166 // containing break points (calls to DebugBreakXXX builtins). |
| 154 Address OriginalCodeAddress() const; | 167 Address OriginalCodeAddress() const; |
| 155 #endif | 168 #endif |
| 156 | 169 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 virtual Handle<Code> generic_stub() const { | 232 virtual Handle<Code> generic_stub() const { |
| 220 UNREACHABLE(); | 233 UNREACHABLE(); |
| 221 return Handle<Code>::null(); | 234 return Handle<Code>::null(); |
| 222 } | 235 } |
| 223 virtual StrictModeFlag strict_mode() const { return kNonStrictMode; } | 236 virtual StrictModeFlag strict_mode() const { return kNonStrictMode; } |
| 224 bool TryRemoveInvalidPrototypeDependentStub(Handle<Object> receiver, | 237 bool TryRemoveInvalidPrototypeDependentStub(Handle<Object> receiver, |
| 225 Handle<String> name); | 238 Handle<String> name); |
| 226 void TryRemoveInvalidHandlers(Handle<Map> map, Handle<String> name); | 239 void TryRemoveInvalidHandlers(Handle<Map> map, Handle<String> name); |
| 227 | 240 |
| 228 private: | 241 private: |
| 242 Code* raw_target() const { return GetTargetAtAddress(address()); } |
| 243 |
| 229 // Frame pointer for the frame that uses (calls) the IC. | 244 // Frame pointer for the frame that uses (calls) the IC. |
| 230 Address fp_; | 245 Address fp_; |
| 231 | 246 |
| 232 // All access to the program counter of an IC structure is indirect | 247 // All access to the program counter of an IC structure is indirect |
| 233 // to make the code GC safe. This feature is crucial since | 248 // to make the code GC safe. This feature is crucial since |
| 234 // GetProperty and SetProperty are called and they in turn might | 249 // GetProperty and SetProperty are called and they in turn might |
| 235 // invoke the garbage collector. | 250 // invoke the garbage collector. |
| 236 Address* pc_address_; | 251 Address* pc_address_; |
| 237 | 252 |
| 238 Isolate* isolate_; | 253 Isolate* isolate_; |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 | 396 |
| 382 static void GenerateMegamorphic(MacroAssembler* masm, int argc); | 397 static void GenerateMegamorphic(MacroAssembler* masm, int argc); |
| 383 static void GenerateNormal(MacroAssembler* masm, int argc); | 398 static void GenerateNormal(MacroAssembler* masm, int argc); |
| 384 static void GenerateNonStrictArguments(MacroAssembler* masm, int argc); | 399 static void GenerateNonStrictArguments(MacroAssembler* masm, int argc); |
| 385 }; | 400 }; |
| 386 | 401 |
| 387 | 402 |
| 388 class LoadIC: public IC { | 403 class LoadIC: public IC { |
| 389 public: | 404 public: |
| 390 explicit LoadIC(FrameDepth depth, Isolate* isolate) : IC(depth, isolate) { | 405 explicit LoadIC(FrameDepth depth, Isolate* isolate) : IC(depth, isolate) { |
| 391 ASSERT(target()->is_load_stub() || target()->is_keyed_load_stub()); | 406 ASSERT(IsLoadStub()); |
| 392 } | 407 } |
| 393 | 408 |
| 394 // Code generator routines. | 409 // Code generator routines. |
| 395 static void GenerateInitialize(MacroAssembler* masm) { GenerateMiss(masm); } | 410 static void GenerateInitialize(MacroAssembler* masm) { GenerateMiss(masm); } |
| 396 static void GeneratePreMonomorphic(MacroAssembler* masm) { | 411 static void GeneratePreMonomorphic(MacroAssembler* masm) { |
| 397 GenerateMiss(masm); | 412 GenerateMiss(masm); |
| 398 } | 413 } |
| 399 static void GenerateMiss(MacroAssembler* masm); | 414 static void GenerateMiss(MacroAssembler* masm); |
| 400 static void GenerateMegamorphic(MacroAssembler* masm); | 415 static void GenerateMegamorphic(MacroAssembler* masm); |
| 401 static void GenerateNormal(MacroAssembler* masm); | 416 static void GenerateNormal(MacroAssembler* masm); |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 531 | 546 |
| 532 friend class IC; | 547 friend class IC; |
| 533 }; | 548 }; |
| 534 | 549 |
| 535 | 550 |
| 536 class StoreIC: public IC { | 551 class StoreIC: public IC { |
| 537 public: | 552 public: |
| 538 StoreIC(FrameDepth depth, Isolate* isolate) | 553 StoreIC(FrameDepth depth, Isolate* isolate) |
| 539 : IC(depth, isolate), | 554 : IC(depth, isolate), |
| 540 strict_mode_(Code::GetStrictMode(target()->extra_ic_state())) { | 555 strict_mode_(Code::GetStrictMode(target()->extra_ic_state())) { |
| 541 ASSERT(target()->is_store_stub() || target()->is_keyed_store_stub()); | 556 ASSERT(IsStoreStub()); |
| 542 } | 557 } |
| 543 | 558 |
| 544 virtual StrictModeFlag strict_mode() const { return strict_mode_; } | 559 virtual StrictModeFlag strict_mode() const { return strict_mode_; } |
| 545 | 560 |
| 546 // Code generators for stub routines. Only called once at startup. | 561 // Code generators for stub routines. Only called once at startup. |
| 547 static void GenerateSlow(MacroAssembler* masm); | 562 static void GenerateSlow(MacroAssembler* masm); |
| 548 static void GenerateInitialize(MacroAssembler* masm) { GenerateMiss(masm); } | 563 static void GenerateInitialize(MacroAssembler* masm) { GenerateMiss(masm); } |
| 549 static void GeneratePreMonomorphic(MacroAssembler* masm) { | 564 static void GeneratePreMonomorphic(MacroAssembler* masm) { |
| 550 GenerateMiss(masm); | 565 GenerateMiss(masm); |
| 551 } | 566 } |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 814 Handle<Type>* left_type, | 829 Handle<Type>* left_type, |
| 815 Handle<Type>* right_type, | 830 Handle<Type>* right_type, |
| 816 Handle<Type>* overall_type, | 831 Handle<Type>* overall_type, |
| 817 Handle<Map> map, | 832 Handle<Map> map, |
| 818 Isolate* isolate); | 833 Isolate* isolate); |
| 819 | 834 |
| 820 CompareIC(Isolate* isolate, Token::Value op) | 835 CompareIC(Isolate* isolate, Token::Value op) |
| 821 : IC(EXTRA_CALL_FRAME, isolate), op_(op) { } | 836 : IC(EXTRA_CALL_FRAME, isolate), op_(op) { } |
| 822 | 837 |
| 823 // Update the inline cache for the given operands. | 838 // Update the inline cache for the given operands. |
| 824 void UpdateCaches(Handle<Object> x, Handle<Object> y); | 839 Code* UpdateCaches(Handle<Object> x, Handle<Object> y); |
| 825 | 840 |
| 826 | 841 |
| 827 // Factory method for getting an uninitialized compare stub. | 842 // Factory method for getting an uninitialized compare stub. |
| 828 static Handle<Code> GetUninitialized(Isolate* isolate, Token::Value op); | 843 static Handle<Code> GetUninitialized(Isolate* isolate, Token::Value op); |
| 829 | 844 |
| 830 // Helper function for computing the condition for a compare operation. | 845 // Helper function for computing the condition for a compare operation. |
| 831 static Condition ComputeCondition(Token::Value op); | 846 static Condition ComputeCondition(Token::Value op); |
| 832 | 847 |
| 833 static const char* GetStateName(State state); | 848 static const char* GetStateName(State state); |
| 834 | 849 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 867 | 882 |
| 868 static MUST_USE_RESULT MaybeObject* DoCompareNilSlow(NilValue nil, | 883 static MUST_USE_RESULT MaybeObject* DoCompareNilSlow(NilValue nil, |
| 869 Handle<Object> object); | 884 Handle<Object> object); |
| 870 }; | 885 }; |
| 871 | 886 |
| 872 | 887 |
| 873 class ToBooleanIC: public IC { | 888 class ToBooleanIC: public IC { |
| 874 public: | 889 public: |
| 875 explicit ToBooleanIC(Isolate* isolate) : IC(EXTRA_CALL_FRAME, isolate) { } | 890 explicit ToBooleanIC(Isolate* isolate) : IC(EXTRA_CALL_FRAME, isolate) { } |
| 876 | 891 |
| 877 MaybeObject* ToBoolean(Handle<Object> object, Code::ExtraICState state); | 892 MaybeObject* ToBoolean(Handle<Object> object); |
| 878 }; | 893 }; |
| 879 | 894 |
| 880 | 895 |
| 881 // Helper for BinaryOpIC and CompareIC. | 896 // Helper for BinaryOpIC and CompareIC. |
| 882 enum InlinedSmiCheck { ENABLE_INLINED_SMI_CHECK, DISABLE_INLINED_SMI_CHECK }; | 897 enum InlinedSmiCheck { ENABLE_INLINED_SMI_CHECK, DISABLE_INLINED_SMI_CHECK }; |
| 883 void PatchInlinedSmiCode(Address address, InlinedSmiCheck check); | 898 void PatchInlinedSmiCode(Address address, InlinedSmiCheck check); |
| 884 | 899 |
| 885 DECLARE_RUNTIME_FUNCTION(MaybeObject*, KeyedLoadIC_MissFromStubFailure); | 900 DECLARE_RUNTIME_FUNCTION(MaybeObject*, KeyedLoadIC_MissFromStubFailure); |
| 886 DECLARE_RUNTIME_FUNCTION(MaybeObject*, KeyedStoreIC_MissFromStubFailure); | 901 DECLARE_RUNTIME_FUNCTION(MaybeObject*, KeyedStoreIC_MissFromStubFailure); |
| 887 DECLARE_RUNTIME_FUNCTION(MaybeObject*, UnaryOpIC_Miss); | 902 DECLARE_RUNTIME_FUNCTION(MaybeObject*, UnaryOpIC_Miss); |
| 888 DECLARE_RUNTIME_FUNCTION(MaybeObject*, StoreIC_MissFromStubFailure); | 903 DECLARE_RUNTIME_FUNCTION(MaybeObject*, StoreIC_MissFromStubFailure); |
| 889 DECLARE_RUNTIME_FUNCTION(MaybeObject*, ElementsTransitionAndStoreIC_Miss); | 904 DECLARE_RUNTIME_FUNCTION(MaybeObject*, ElementsTransitionAndStoreIC_Miss); |
| 890 DECLARE_RUNTIME_FUNCTION(MaybeObject*, BinaryOpIC_Miss); | 905 DECLARE_RUNTIME_FUNCTION(MaybeObject*, BinaryOpIC_Miss); |
| 891 DECLARE_RUNTIME_FUNCTION(MaybeObject*, CompareNilIC_Miss); | 906 DECLARE_RUNTIME_FUNCTION(MaybeObject*, CompareNilIC_Miss); |
| 892 DECLARE_RUNTIME_FUNCTION(MaybeObject*, ToBooleanIC_Miss); | 907 DECLARE_RUNTIME_FUNCTION(MaybeObject*, ToBooleanIC_Miss); |
| 893 | 908 |
| 894 | 909 |
| 895 } } // namespace v8::internal | 910 } } // namespace v8::internal |
| 896 | 911 |
| 897 #endif // V8_IC_H_ | 912 #endif // V8_IC_H_ |
| OLD | NEW |