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