| 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 State state() const { return state_; } | 94 State state() const { return state_; } |
| 95 inline Address address() const; | 95 inline Address address() const; |
| 96 | 96 |
| 97 // Compute the current IC state based on the target stub, receiver and name. | 97 // Compute the current IC state based on the target stub, receiver and name. |
| 98 void UpdateState(Handle<Object> receiver, Handle<Object> name); | 98 void UpdateState(Handle<Object> receiver, Handle<Object> name); |
| 99 void MarkMonomorphicPrototypeFailure() { | 99 void MarkMonomorphicPrototypeFailure() { |
| 100 state_ = MONOMORPHIC_PROTOTYPE_FAILURE; | 100 state_ = MONOMORPHIC_PROTOTYPE_FAILURE; |
| 101 } | 101 } |
| 102 | 102 |
| 103 // Clear the inline cache to initial state. | 103 // Clear the inline cache to initial state. |
| 104 static void Clear(Isolate* isolate, | 104 static void Clear(Isolate* isolate, Address address); |
| 105 Address address, | |
| 106 ConstantPoolArray* constant_pool); | |
| 107 | 105 |
| 108 #ifdef DEBUG | 106 #ifdef DEBUG |
| 109 bool IsLoadStub() const { | 107 bool IsLoadStub() const { |
| 110 return target()->is_load_stub() || target()->is_keyed_load_stub(); | 108 return target()->is_load_stub() || target()->is_keyed_load_stub(); |
| 111 } | 109 } |
| 112 | 110 |
| 113 bool IsStoreStub() const { | 111 bool IsStoreStub() const { |
| 114 return target()->is_store_stub() || target()->is_keyed_store_stub(); | 112 return target()->is_store_stub() || target()->is_keyed_store_stub(); |
| 115 } | 113 } |
| 116 #endif | 114 #endif |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 | 148 |
| 151 protected: | 149 protected: |
| 152 // Get the call-site target; used for determining the state. | 150 // Get the call-site target; used for determining the state. |
| 153 Handle<Code> target() const { return target_; } | 151 Handle<Code> target() const { return target_; } |
| 154 | 152 |
| 155 Address fp() const { return fp_; } | 153 Address fp() const { return fp_; } |
| 156 Address pc() const { return *pc_address_; } | 154 Address pc() const { return *pc_address_; } |
| 157 Isolate* isolate() const { return isolate_; } | 155 Isolate* isolate() const { return isolate_; } |
| 158 | 156 |
| 159 #ifdef ENABLE_DEBUGGER_SUPPORT | 157 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 160 // Get the shared function info of the caller. | 158 // Computes the address in the original code when the code running is |
| 161 SharedFunctionInfo* GetSharedFunctionInfo() const; | 159 // containing break points (calls to DebugBreakXXX builtins). |
| 162 // Get the code object of the caller. | 160 Address OriginalCodeAddress() const; |
| 163 Code* GetCode() const; | |
| 164 // Get the original (non-breakpointed) code object of the caller. | |
| 165 Code* GetOriginalCode() const; | |
| 166 #endif | 161 #endif |
| 167 | 162 |
| 168 // Set the call-site target. | 163 // Set the call-site target. |
| 169 void set_target(Code* code) { | 164 void set_target(Code* code) { |
| 170 SetTargetAtAddress(address(), code, constant_pool()); | 165 SetTargetAtAddress(address(), code); |
| 171 target_set_ = true; | 166 target_set_ = true; |
| 172 } | 167 } |
| 173 | 168 |
| 174 bool is_target_set() { return target_set_; } | 169 bool is_target_set() { return target_set_; } |
| 175 | 170 |
| 176 #ifdef DEBUG | 171 #ifdef DEBUG |
| 177 char TransitionMarkFromState(IC::State state); | 172 char TransitionMarkFromState(IC::State state); |
| 178 | 173 |
| 179 void TraceIC(const char* type, Handle<Object> name); | 174 void TraceIC(const char* type, Handle<Object> name); |
| 180 #endif | 175 #endif |
| 181 | 176 |
| 182 Failure* TypeError(const char* type, | 177 Failure* TypeError(const char* type, |
| 183 Handle<Object> object, | 178 Handle<Object> object, |
| 184 Handle<Object> key); | 179 Handle<Object> key); |
| 185 Failure* ReferenceError(const char* type, Handle<String> name); | 180 Failure* ReferenceError(const char* type, Handle<String> name); |
| 186 | 181 |
| 187 // Access the target code for the given IC address. | 182 // Access the target code for the given IC address. |
| 188 static inline Code* GetTargetAtAddress(Address address, | 183 static inline Code* GetTargetAtAddress(Address address); |
| 189 ConstantPoolArray* constant_pool); | 184 static inline void SetTargetAtAddress(Address address, Code* target); |
| 190 static inline void SetTargetAtAddress(Address address, | |
| 191 Code* target, | |
| 192 ConstantPoolArray* constant_pool); | |
| 193 static void PostPatching(Address address, Code* target, Code* old_target); | 185 static void PostPatching(Address address, Code* target, Code* old_target); |
| 194 | 186 |
| 195 // Compute the handler either by compiling or by retrieving a cached version. | 187 // Compute the handler either by compiling or by retrieving a cached version. |
| 196 Handle<Code> ComputeHandler(LookupResult* lookup, | 188 Handle<Code> ComputeHandler(LookupResult* lookup, |
| 197 Handle<Object> object, | 189 Handle<Object> object, |
| 198 Handle<String> name, | 190 Handle<String> name, |
| 199 Handle<Object> value = Handle<Code>::null()); | 191 Handle<Object> value = Handle<Code>::null()); |
| 200 virtual Handle<Code> CompileHandler(LookupResult* lookup, | 192 virtual Handle<Code> CompileHandler(LookupResult* lookup, |
| 201 Handle<Object> object, | 193 Handle<Object> object, |
| 202 Handle<String> name, | 194 Handle<String> name, |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 bool TryRemoveInvalidPrototypeDependentStub(Handle<Object> receiver, | 233 bool TryRemoveInvalidPrototypeDependentStub(Handle<Object> receiver, |
| 242 Handle<String> name); | 234 Handle<String> name); |
| 243 void TryRemoveInvalidHandlers(Handle<Map> map, Handle<String> name); | 235 void TryRemoveInvalidHandlers(Handle<Map> map, Handle<String> name); |
| 244 | 236 |
| 245 ExtraICState extra_ic_state() const { return extra_ic_state_; } | 237 ExtraICState extra_ic_state() const { return extra_ic_state_; } |
| 246 void set_extra_ic_state(ExtraICState state) { | 238 void set_extra_ic_state(ExtraICState state) { |
| 247 extra_ic_state_ = state; | 239 extra_ic_state_ = state; |
| 248 } | 240 } |
| 249 | 241 |
| 250 private: | 242 private: |
| 251 Code* raw_target() const { | 243 Code* raw_target() const { return GetTargetAtAddress(address()); } |
| 252 return GetTargetAtAddress(address(), constant_pool()); | |
| 253 } | |
| 254 inline ConstantPoolArray* constant_pool() const; | |
| 255 inline ConstantPoolArray* raw_constant_pool() const; | |
| 256 | 244 |
| 257 // Frame pointer for the frame that uses (calls) the IC. | 245 // Frame pointer for the frame that uses (calls) the IC. |
| 258 Address fp_; | 246 Address fp_; |
| 259 | 247 |
| 260 // All access to the program counter of an IC structure is indirect | 248 // All access to the program counter of an IC structure is indirect |
| 261 // to make the code GC safe. This feature is crucial since | 249 // to make the code GC safe. This feature is crucial since |
| 262 // GetProperty and SetProperty are called and they in turn might | 250 // GetProperty and SetProperty are called and they in turn might |
| 263 // invoke the garbage collector. | 251 // invoke the garbage collector. |
| 264 Address* pc_address_; | 252 Address* pc_address_; |
| 265 | 253 |
| 266 Isolate* isolate_; | 254 Isolate* isolate_; |
| 267 | 255 |
| 268 // The constant pool of the code which originally called the IC (which might | |
| 269 // be for the breakpointed copy of the original code). | |
| 270 Handle<ConstantPoolArray> raw_constant_pool_; | |
| 271 | |
| 272 // The original code target that missed. | 256 // The original code target that missed. |
| 273 Handle<Code> target_; | 257 Handle<Code> target_; |
| 274 State state_; | 258 State state_; |
| 275 bool target_set_; | 259 bool target_set_; |
| 276 | 260 |
| 277 ExtraICState extra_ic_state_; | 261 ExtraICState extra_ic_state_; |
| 278 | 262 |
| 279 DISALLOW_IMPLICIT_CONSTRUCTORS(IC); | 263 DISALLOW_IMPLICIT_CONSTRUCTORS(IC); |
| 280 }; | 264 }; |
| 281 | 265 |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 | 366 |
| 383 virtual Handle<Code> pre_monomorphic_stub() { | 367 virtual Handle<Code> pre_monomorphic_stub() { |
| 384 return pre_monomorphic_stub(isolate(), extra_ic_state()); | 368 return pre_monomorphic_stub(isolate(), extra_ic_state()); |
| 385 } | 369 } |
| 386 | 370 |
| 387 Handle<Code> SimpleFieldLoad(int offset, | 371 Handle<Code> SimpleFieldLoad(int offset, |
| 388 bool inobject = true, | 372 bool inobject = true, |
| 389 Representation representation = | 373 Representation representation = |
| 390 Representation::Tagged()); | 374 Representation::Tagged()); |
| 391 | 375 |
| 392 static void Clear(Isolate* isolate, | 376 static void Clear(Isolate* isolate, Address address, Code* target); |
| 393 Address address, | |
| 394 Code* target, | |
| 395 ConstantPoolArray* constant_pool); | |
| 396 | 377 |
| 397 friend class IC; | 378 friend class IC; |
| 398 }; | 379 }; |
| 399 | 380 |
| 400 | 381 |
| 401 class KeyedLoadIC: public LoadIC { | 382 class KeyedLoadIC: public LoadIC { |
| 402 public: | 383 public: |
| 403 explicit KeyedLoadIC(FrameDepth depth, Isolate* isolate) | 384 explicit KeyedLoadIC(FrameDepth depth, Isolate* isolate) |
| 404 : LoadIC(depth, isolate) { | 385 : LoadIC(depth, isolate) { |
| 405 ASSERT(target()->is_keyed_load_stub()); | 386 ASSERT(target()->is_keyed_load_stub()); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 455 Handle<Code> indexed_interceptor_stub() { | 436 Handle<Code> indexed_interceptor_stub() { |
| 456 return isolate()->builtins()->KeyedLoadIC_IndexedInterceptor(); | 437 return isolate()->builtins()->KeyedLoadIC_IndexedInterceptor(); |
| 457 } | 438 } |
| 458 Handle<Code> sloppy_arguments_stub() { | 439 Handle<Code> sloppy_arguments_stub() { |
| 459 return isolate()->builtins()->KeyedLoadIC_SloppyArguments(); | 440 return isolate()->builtins()->KeyedLoadIC_SloppyArguments(); |
| 460 } | 441 } |
| 461 Handle<Code> string_stub() { | 442 Handle<Code> string_stub() { |
| 462 return isolate()->builtins()->KeyedLoadIC_String(); | 443 return isolate()->builtins()->KeyedLoadIC_String(); |
| 463 } | 444 } |
| 464 | 445 |
| 465 static void Clear(Isolate* isolate, | 446 static void Clear(Isolate* isolate, Address address, Code* target); |
| 466 Address address, | |
| 467 Code* target, | |
| 468 ConstantPoolArray* constant_pool); | |
| 469 | 447 |
| 470 friend class IC; | 448 friend class IC; |
| 471 }; | 449 }; |
| 472 | 450 |
| 473 | 451 |
| 474 class StoreIC: public IC { | 452 class StoreIC: public IC { |
| 475 public: | 453 public: |
| 476 class StrictModeState: public BitField<StrictMode, 1, 1> {}; | 454 class StrictModeState: public BitField<StrictMode, 1, 1> {}; |
| 477 static ExtraICState ComputeExtraICState(StrictMode flag) { | 455 static ExtraICState ComputeExtraICState(StrictMode flag) { |
| 478 return StrictModeState::encode(flag); | 456 return StrictModeState::encode(flag); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 548 InlineCacheHolderFlag cache_holder); | 526 InlineCacheHolderFlag cache_holder); |
| 549 | 527 |
| 550 private: | 528 private: |
| 551 void set_target(Code* code) { | 529 void set_target(Code* code) { |
| 552 // Strict mode must be preserved across IC patching. | 530 // Strict mode must be preserved across IC patching. |
| 553 ASSERT(GetStrictMode(code->extra_ic_state()) == | 531 ASSERT(GetStrictMode(code->extra_ic_state()) == |
| 554 GetStrictMode(target()->extra_ic_state())); | 532 GetStrictMode(target()->extra_ic_state())); |
| 555 IC::set_target(code); | 533 IC::set_target(code); |
| 556 } | 534 } |
| 557 | 535 |
| 558 static void Clear(Isolate* isolate, | 536 static void Clear(Isolate* isolate, Address address, Code* target); |
| 559 Address address, | |
| 560 Code* target, | |
| 561 ConstantPoolArray* constant_pool); | |
| 562 | 537 |
| 563 friend class IC; | 538 friend class IC; |
| 564 }; | 539 }; |
| 565 | 540 |
| 566 | 541 |
| 567 enum KeyedStoreCheckMap { | 542 enum KeyedStoreCheckMap { |
| 568 kDontCheckMap, | 543 kDontCheckMap, |
| 569 kCheckMap | 544 kCheckMap |
| 570 }; | 545 }; |
| 571 | 546 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 658 return isolate()->builtins()->KeyedStoreIC_Generic_Strict(); | 633 return isolate()->builtins()->KeyedStoreIC_Generic_Strict(); |
| 659 } else { | 634 } else { |
| 660 return isolate()->builtins()->KeyedStoreIC_Generic(); | 635 return isolate()->builtins()->KeyedStoreIC_Generic(); |
| 661 } | 636 } |
| 662 } | 637 } |
| 663 | 638 |
| 664 Handle<Code> sloppy_arguments_stub() { | 639 Handle<Code> sloppy_arguments_stub() { |
| 665 return isolate()->builtins()->KeyedStoreIC_SloppyArguments(); | 640 return isolate()->builtins()->KeyedStoreIC_SloppyArguments(); |
| 666 } | 641 } |
| 667 | 642 |
| 668 static void Clear(Isolate* isolate, | 643 static void Clear(Isolate* isolate, Address address, Code* target); |
| 669 Address address, | |
| 670 Code* target, | |
| 671 ConstantPoolArray* constant_pool); | |
| 672 | 644 |
| 673 KeyedAccessStoreMode GetStoreMode(Handle<JSObject> receiver, | 645 KeyedAccessStoreMode GetStoreMode(Handle<JSObject> receiver, |
| 674 Handle<Object> key, | 646 Handle<Object> key, |
| 675 Handle<Object> value); | 647 Handle<Object> value); |
| 676 | 648 |
| 677 Handle<Map> ComputeTransitionedMap(Handle<JSObject> receiver, | 649 Handle<Map> ComputeTransitionedMap(Handle<JSObject> receiver, |
| 678 KeyedAccessStoreMode store_mode); | 650 KeyedAccessStoreMode store_mode); |
| 679 | 651 |
| 680 friend class IC; | 652 friend class IC; |
| 681 }; | 653 }; |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 868 State old_right, | 840 State old_right, |
| 869 bool has_inlined_smi_code, | 841 bool has_inlined_smi_code, |
| 870 Handle<Object> x, | 842 Handle<Object> x, |
| 871 Handle<Object> y); | 843 Handle<Object> y); |
| 872 | 844 |
| 873 bool strict() const { return op_ == Token::EQ_STRICT; } | 845 bool strict() const { return op_ == Token::EQ_STRICT; } |
| 874 Condition GetCondition() const { return ComputeCondition(op_); } | 846 Condition GetCondition() const { return ComputeCondition(op_); } |
| 875 | 847 |
| 876 static Code* GetRawUninitialized(Isolate* isolate, Token::Value op); | 848 static Code* GetRawUninitialized(Isolate* isolate, Token::Value op); |
| 877 | 849 |
| 878 static void Clear(Isolate* isolate, | 850 static void Clear(Isolate* isolate, Address address, Code* target); |
| 879 Address address, | |
| 880 Code* target, | |
| 881 ConstantPoolArray* constant_pool); | |
| 882 | 851 |
| 883 Token::Value op_; | 852 Token::Value op_; |
| 884 | 853 |
| 885 friend class IC; | 854 friend class IC; |
| 886 }; | 855 }; |
| 887 | 856 |
| 888 | 857 |
| 889 class CompareNilIC: public IC { | 858 class CompareNilIC: public IC { |
| 890 public: | 859 public: |
| 891 explicit CompareNilIC(Isolate* isolate) : IC(EXTRA_CALL_FRAME, isolate) {} | 860 explicit CompareNilIC(Isolate* isolate) : IC(EXTRA_CALL_FRAME, isolate) {} |
| 892 | 861 |
| 893 MUST_USE_RESULT MaybeObject* CompareNil(Handle<Object> object); | 862 MUST_USE_RESULT MaybeObject* CompareNil(Handle<Object> object); |
| 894 | 863 |
| 895 static Handle<Code> GetUninitialized(); | 864 static Handle<Code> GetUninitialized(); |
| 896 | 865 |
| 897 static void Clear(Address address, | 866 static void Clear(Address address, Code* target); |
| 898 Code* target, | |
| 899 ConstantPoolArray* constant_pool); | |
| 900 | 867 |
| 901 static MUST_USE_RESULT MaybeObject* DoCompareNilSlow(NilValue nil, | 868 static MUST_USE_RESULT MaybeObject* DoCompareNilSlow(NilValue nil, |
| 902 Handle<Object> object); | 869 Handle<Object> object); |
| 903 }; | 870 }; |
| 904 | 871 |
| 905 | 872 |
| 906 class ToBooleanIC: public IC { | 873 class ToBooleanIC: public IC { |
| 907 public: | 874 public: |
| 908 explicit ToBooleanIC(Isolate* isolate) : IC(EXTRA_CALL_FRAME, isolate) { } | 875 explicit ToBooleanIC(Isolate* isolate) : IC(EXTRA_CALL_FRAME, isolate) { } |
| 909 | 876 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 922 DECLARE_RUNTIME_FUNCTION(MaybeObject*, ElementsTransitionAndStoreIC_Miss); | 889 DECLARE_RUNTIME_FUNCTION(MaybeObject*, ElementsTransitionAndStoreIC_Miss); |
| 923 DECLARE_RUNTIME_FUNCTION(MaybeObject*, BinaryOpIC_Miss); | 890 DECLARE_RUNTIME_FUNCTION(MaybeObject*, BinaryOpIC_Miss); |
| 924 DECLARE_RUNTIME_FUNCTION(MaybeObject*, BinaryOpIC_MissWithAllocationSite); | 891 DECLARE_RUNTIME_FUNCTION(MaybeObject*, BinaryOpIC_MissWithAllocationSite); |
| 925 DECLARE_RUNTIME_FUNCTION(MaybeObject*, CompareNilIC_Miss); | 892 DECLARE_RUNTIME_FUNCTION(MaybeObject*, CompareNilIC_Miss); |
| 926 DECLARE_RUNTIME_FUNCTION(MaybeObject*, ToBooleanIC_Miss); | 893 DECLARE_RUNTIME_FUNCTION(MaybeObject*, ToBooleanIC_Miss); |
| 927 | 894 |
| 928 | 895 |
| 929 } } // namespace v8::internal | 896 } } // namespace v8::internal |
| 930 | 897 |
| 931 #endif // V8_IC_H_ | 898 #endif // V8_IC_H_ |
| OLD | NEW |