| 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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 JSObject* holder); | 129 JSObject* holder); |
| 130 static inline InlineCacheHolderFlag GetCodeCacheForObject(JSObject* object, | 130 static inline InlineCacheHolderFlag GetCodeCacheForObject(JSObject* object, |
| 131 JSObject* holder); | 131 JSObject* holder); |
| 132 static inline JSObject* GetCodeCacheHolder(Object* object, | 132 static inline JSObject* GetCodeCacheHolder(Object* object, |
| 133 InlineCacheHolderFlag holder); | 133 InlineCacheHolderFlag holder); |
| 134 | 134 |
| 135 MUST_USE_RESULT MaybeObject* Load(State state, | 135 MUST_USE_RESULT MaybeObject* Load(State state, |
| 136 Handle<Object> object, | 136 Handle<Object> object, |
| 137 Handle<String> name); | 137 Handle<String> name); |
| 138 | 138 |
| 139 MUST_USE_RESULT MaybeObject* Store( |
| 140 State state, |
| 141 StrictModeFlag strict_mode, |
| 142 Handle<Object> object, |
| 143 Handle<String> name, |
| 144 Handle<Object> value, |
| 145 JSReceiver::StoreFromKeyed store_mode = |
| 146 JSReceiver::CERTAINLY_NOT_STORE_FROM_KEYED); |
| 147 |
| 139 protected: | 148 protected: |
| 140 virtual Handle<Code> pre_monomorphic_stub() { | 149 virtual Handle<Code> pre_monomorphic_stub() { |
| 141 UNREACHABLE(); | 150 UNREACHABLE(); |
| 142 return Handle<Code>::null(); | 151 return Handle<Code>::null(); |
| 143 } | 152 } |
| 144 virtual Handle<Code> megamorphic_stub() { | 153 virtual Handle<Code> megamorphic_stub() { |
| 145 UNREACHABLE(); | 154 UNREACHABLE(); |
| 146 return Handle<Code>::null(); | 155 return Handle<Code>::null(); |
| 147 } | 156 } |
| 157 virtual Handle<Code> megamorphic_stub_strict() { |
| 158 UNREACHABLE(); |
| 159 return Handle<Code>::null(); |
| 160 } |
| 148 virtual Handle<Code> generic_stub() const { | 161 virtual Handle<Code> generic_stub() const { |
| 149 UNREACHABLE(); | 162 UNREACHABLE(); |
| 150 return Handle<Code>::null(); | 163 return Handle<Code>::null(); |
| 151 } | 164 } |
| 152 virtual Code::Kind kind() const { | 165 virtual Code::Kind kind() const { |
| 153 UNREACHABLE(); | 166 UNREACHABLE(); |
| 154 return Code::STUB; | 167 return Code::STUB; |
| 155 } | 168 } |
| 169 virtual Handle<Code> global_proxy_stub() { |
| 170 UNREACHABLE(); |
| 171 return Handle<Code>::null(); |
| 172 } |
| 173 virtual Handle<Code> global_proxy_stub_strict() { |
| 174 UNREACHABLE(); |
| 175 return Handle<Code>::null(); |
| 176 } |
| 177 |
| 156 virtual void UpdateLoadCaches(LookupResult* lookup, | 178 virtual void UpdateLoadCaches(LookupResult* lookup, |
| 157 State state, | 179 State state, |
| 158 Handle<Object> object, | 180 Handle<Object> object, |
| 159 Handle<String> name) { | 181 Handle<String> name) { |
| 160 UNREACHABLE(); | 182 UNREACHABLE(); |
| 161 } | 183 } |
| 184 virtual void UpdateStoreCaches(LookupResult* lookup, |
| 185 State state, |
| 186 StrictModeFlag strict_mode, |
| 187 Handle<JSObject> receiver, |
| 188 Handle<String> name, |
| 189 Handle<Object> value) { |
| 190 UNREACHABLE(); |
| 191 } |
| 162 Address fp() const { return fp_; } | 192 Address fp() const { return fp_; } |
| 163 Address pc() const { return *pc_address_; } | 193 Address pc() const { return *pc_address_; } |
| 164 Isolate* isolate() const { return isolate_; } | 194 Isolate* isolate() const { return isolate_; } |
| 165 | 195 |
| 166 #ifdef ENABLE_DEBUGGER_SUPPORT | 196 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 167 // Computes the address in the original code when the code running is | 197 // Computes the address in the original code when the code running is |
| 168 // containing break points (calls to DebugBreakXXX builtins). | 198 // containing break points (calls to DebugBreakXXX builtins). |
| 169 Address OriginalCodeAddress() const; | 199 Address OriginalCodeAddress() const; |
| 170 #endif | 200 #endif |
| 171 | 201 |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 | 401 |
| 372 // Update the inline cache and the global stub cache based on the | 402 // Update the inline cache and the global stub cache based on the |
| 373 // lookup result. | 403 // lookup result. |
| 374 virtual void UpdateLoadCaches(LookupResult* lookup, | 404 virtual void UpdateLoadCaches(LookupResult* lookup, |
| 375 State state, | 405 State state, |
| 376 Handle<Object> object, | 406 Handle<Object> object, |
| 377 Handle<String> name); | 407 Handle<String> name); |
| 378 | 408 |
| 379 private: | 409 private: |
| 380 // Stub accessors. | 410 // Stub accessors. |
| 381 static Code* initialize_stub() { | 411 static Handle<Code> initialize_stub() { |
| 382 return Isolate::Current()->builtins()->builtin( | 412 return Isolate::Current()->builtins()->LoadIC_Initialize(); |
| 383 Builtins::kLoadIC_Initialize); | |
| 384 } | 413 } |
| 385 virtual Handle<Code> pre_monomorphic_stub() { | 414 virtual Handle<Code> pre_monomorphic_stub() { |
| 386 return isolate()->builtins()->LoadIC_PreMonomorphic(); | 415 return isolate()->builtins()->LoadIC_PreMonomorphic(); |
| 387 } | 416 } |
| 388 | 417 |
| 389 static void Clear(Address address, Code* target); | 418 static void Clear(Address address, Code* target); |
| 390 | 419 |
| 391 friend class IC; | 420 friend class IC; |
| 392 }; | 421 }; |
| 393 | 422 |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 } | 587 } |
| 559 | 588 |
| 560 // Update the inline cache. | 589 // Update the inline cache. |
| 561 virtual void UpdateLoadCaches(LookupResult* lookup, | 590 virtual void UpdateLoadCaches(LookupResult* lookup, |
| 562 State state, | 591 State state, |
| 563 Handle<Object> object, | 592 Handle<Object> object, |
| 564 Handle<String> name); | 593 Handle<String> name); |
| 565 | 594 |
| 566 private: | 595 private: |
| 567 // Stub accessors. | 596 // Stub accessors. |
| 568 static Code* initialize_stub() { | 597 static Handle<Code> initialize_stub() { |
| 569 return Isolate::Current()->builtins()->builtin( | 598 return Isolate::Current()->builtins()->KeyedLoadIC_Initialize(); |
| 570 Builtins::kKeyedLoadIC_Initialize); | |
| 571 } | 599 } |
| 572 virtual Handle<Code> pre_monomorphic_stub() { | 600 virtual Handle<Code> pre_monomorphic_stub() { |
| 573 return isolate()->builtins()->KeyedLoadIC_PreMonomorphic(); | 601 return isolate()->builtins()->KeyedLoadIC_PreMonomorphic(); |
| 574 } | 602 } |
| 575 Handle<Code> indexed_interceptor_stub() { | 603 Handle<Code> indexed_interceptor_stub() { |
| 576 return isolate()->builtins()->KeyedLoadIC_IndexedInterceptor(); | 604 return isolate()->builtins()->KeyedLoadIC_IndexedInterceptor(); |
| 577 } | 605 } |
| 578 Handle<Code> non_strict_arguments_stub() { | 606 Handle<Code> non_strict_arguments_stub() { |
| 579 return isolate()->builtins()->KeyedLoadIC_NonStrictArguments(); | 607 return isolate()->builtins()->KeyedLoadIC_NonStrictArguments(); |
| 580 } | 608 } |
| 581 | 609 |
| 582 static void Clear(Address address, Code* target); | 610 static void Clear(Address address, Code* target); |
| 583 | 611 |
| 584 friend class IC; | 612 friend class IC; |
| 585 }; | 613 }; |
| 586 | 614 |
| 587 | 615 |
| 588 class StoreIC: public IC { | 616 class StoreIC: public IC { |
| 589 public: | 617 public: |
| 590 explicit StoreIC(Isolate* isolate) : IC(NO_EXTRA_FRAME, isolate) { | 618 explicit StoreIC(Isolate* isolate) : IC(NO_EXTRA_FRAME, isolate) { |
| 591 ASSERT(target()->is_store_stub()); | 619 ASSERT(target()->is_store_stub()); |
| 592 } | 620 } |
| 593 | 621 |
| 594 MUST_USE_RESULT MaybeObject* Store(State state, | |
| 595 StrictModeFlag strict_mode, | |
| 596 Handle<Object> object, | |
| 597 Handle<String> name, | |
| 598 Handle<Object> value); | |
| 599 | |
| 600 // Code generators for stub routines. Only called once at startup. | 622 // Code generators for stub routines. Only called once at startup. |
| 601 static void GenerateInitialize(MacroAssembler* masm) { GenerateMiss(masm); } | 623 static void GenerateInitialize(MacroAssembler* masm) { GenerateMiss(masm); } |
| 602 static void GenerateMiss(MacroAssembler* masm); | 624 static void GenerateMiss(MacroAssembler* masm); |
| 603 static void GenerateMegamorphic(MacroAssembler* masm, | 625 static void GenerateMegamorphic(MacroAssembler* masm, |
| 604 StrictModeFlag strict_mode); | 626 StrictModeFlag strict_mode); |
| 605 static void GenerateArrayLength(MacroAssembler* masm); | 627 static void GenerateArrayLength(MacroAssembler* masm); |
| 606 static void GenerateNormal(MacroAssembler* masm); | 628 static void GenerateNormal(MacroAssembler* masm); |
| 607 static void GenerateGlobalProxy(MacroAssembler* masm, | 629 static void GenerateGlobalProxy(MacroAssembler* masm, |
| 608 StrictModeFlag strict_mode); | 630 StrictModeFlag strict_mode); |
| 609 | 631 |
| 610 protected: | 632 protected: |
| 611 virtual Code::Kind kind() const { return Code::STORE_IC; } | 633 virtual Code::Kind kind() const { return Code::STORE_IC; } |
| 612 virtual Handle<Code> megamorphic_stub() { | 634 virtual Handle<Code> megamorphic_stub() { |
| 613 return isolate()->builtins()->StoreIC_Megamorphic(); | 635 return isolate()->builtins()->StoreIC_Megamorphic(); |
| 614 } | 636 } |
| 637 // Stub accessors. |
| 638 virtual Handle<Code> megamorphic_stub_strict() { |
| 639 return isolate()->builtins()->StoreIC_Megamorphic_Strict(); |
| 640 } |
| 641 virtual Handle<Code> global_proxy_stub() { |
| 642 return isolate()->builtins()->StoreIC_GlobalProxy(); |
| 643 } |
| 644 virtual Handle<Code> global_proxy_stub_strict() { |
| 645 return isolate()->builtins()->StoreIC_GlobalProxy_Strict(); |
| 646 } |
| 647 |
| 648 |
| 649 // Update the inline cache and the global stub cache based on the |
| 650 // lookup result. |
| 651 virtual void UpdateStoreCaches(LookupResult* lookup, |
| 652 State state, |
| 653 StrictModeFlag strict_mode, |
| 654 Handle<JSObject> receiver, |
| 655 Handle<String> name, |
| 656 Handle<Object> value); |
| 615 | 657 |
| 616 private: | 658 private: |
| 617 // Update the inline cache and the global stub cache based on the | |
| 618 // lookup result. | |
| 619 void UpdateCaches(LookupResult* lookup, | |
| 620 State state, | |
| 621 StrictModeFlag strict_mode, | |
| 622 Handle<JSObject> receiver, | |
| 623 Handle<String> name, | |
| 624 Handle<Object> value); | |
| 625 | |
| 626 void set_target(Code* code) { | 659 void set_target(Code* code) { |
| 627 // Strict mode must be preserved across IC patching. | 660 // Strict mode must be preserved across IC patching. |
| 628 ASSERT(Code::GetStrictMode(code->extra_ic_state()) == | 661 ASSERT(Code::GetStrictMode(code->extra_ic_state()) == |
| 629 Code::GetStrictMode(target()->extra_ic_state())); | 662 Code::GetStrictMode(target()->extra_ic_state())); |
| 630 IC::set_target(code); | 663 IC::set_target(code); |
| 631 } | 664 } |
| 632 | 665 |
| 633 // Stub accessors. | 666 static Handle<Code> initialize_stub() { |
| 634 Code* megamorphic_stub_strict() { | 667 return Isolate::Current()->builtins()->StoreIC_Initialize(); |
| 635 return isolate()->builtins()->builtin( | |
| 636 Builtins::kStoreIC_Megamorphic_Strict); | |
| 637 } | 668 } |
| 638 static Code* initialize_stub() { | 669 static Handle<Code> initialize_stub_strict() { |
| 639 return Isolate::Current()->builtins()->builtin( | 670 return Isolate::Current()->builtins()->StoreIC_Initialize_Strict(); |
| 640 Builtins::kStoreIC_Initialize); | |
| 641 } | 671 } |
| 642 static Code* initialize_stub_strict() { | |
| 643 return Isolate::Current()->builtins()->builtin( | |
| 644 Builtins::kStoreIC_Initialize_Strict); | |
| 645 } | |
| 646 Handle<Code> global_proxy_stub() { | |
| 647 return isolate()->builtins()->StoreIC_GlobalProxy(); | |
| 648 } | |
| 649 Handle<Code> global_proxy_stub_strict() { | |
| 650 return isolate()->builtins()->StoreIC_GlobalProxy_Strict(); | |
| 651 } | |
| 652 | |
| 653 static void Clear(Address address, Code* target); | 672 static void Clear(Address address, Code* target); |
| 654 | 673 |
| 655 friend class IC; | 674 friend class IC; |
| 656 }; | 675 }; |
| 657 | 676 |
| 658 | 677 |
| 659 enum KeyedStoreCheckMap { | 678 enum KeyedStoreCheckMap { |
| 660 kDontCheckMap, | 679 kDontCheckMap, |
| 661 kCheckMap | 680 kCheckMap |
| 662 }; | 681 }; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 699 ElementsKind elements_kind, | 718 ElementsKind elements_kind, |
| 700 KeyedAccessGrowMode grow_mode); | 719 KeyedAccessGrowMode grow_mode); |
| 701 | 720 |
| 702 protected: | 721 protected: |
| 703 virtual Code::Kind kind() const { return Code::KEYED_STORE_IC; } | 722 virtual Code::Kind kind() const { return Code::KEYED_STORE_IC; } |
| 704 | 723 |
| 705 virtual Handle<Code> ComputePolymorphicStub(MapHandleList* receiver_maps, | 724 virtual Handle<Code> ComputePolymorphicStub(MapHandleList* receiver_maps, |
| 706 StrictModeFlag strict_mode, | 725 StrictModeFlag strict_mode, |
| 707 KeyedAccessGrowMode grow_mode); | 726 KeyedAccessGrowMode grow_mode); |
| 708 | 727 |
| 728 // Update the inline cache. |
| 729 virtual void UpdateStoreCaches(LookupResult* lookup, |
| 730 State state, |
| 731 StrictModeFlag strict_mode, |
| 732 Handle<JSObject> receiver, |
| 733 Handle<String> name, |
| 734 Handle<Object> value); |
| 735 |
| 736 virtual Handle<Code> megamorphic_stub() { |
| 737 return isolate()->builtins()->KeyedStoreIC_Generic(); |
| 738 } |
| 739 virtual Handle<Code> megamorphic_stub_strict() { |
| 740 return isolate()->builtins()->KeyedStoreIC_Generic_Strict(); |
| 741 } |
| 742 |
| 709 private: | 743 private: |
| 710 // Update the inline cache. | |
| 711 void UpdateCaches(LookupResult* lookup, | |
| 712 State state, | |
| 713 StrictModeFlag strict_mode, | |
| 714 Handle<JSObject> receiver, | |
| 715 Handle<String> name, | |
| 716 Handle<Object> value); | |
| 717 | |
| 718 void set_target(Code* code) { | 744 void set_target(Code* code) { |
| 719 // Strict mode must be preserved across IC patching. | 745 // Strict mode must be preserved across IC patching. |
| 720 ASSERT(Code::GetStrictMode(code->extra_ic_state()) == | 746 ASSERT(Code::GetStrictMode(code->extra_ic_state()) == |
| 721 Code::GetStrictMode(target()->extra_ic_state())); | 747 Code::GetStrictMode(target()->extra_ic_state())); |
| 722 IC::set_target(code); | 748 IC::set_target(code); |
| 723 } | 749 } |
| 724 | 750 |
| 725 // Stub accessors. | 751 // Stub accessors. |
| 726 static Code* initialize_stub() { | 752 static Handle<Code> initialize_stub() { |
| 727 return Isolate::Current()->builtins()->builtin( | 753 return Isolate::Current()->builtins()->KeyedStoreIC_Initialize(); |
| 728 Builtins::kKeyedStoreIC_Initialize); | |
| 729 } | 754 } |
| 730 static Code* initialize_stub_strict() { | 755 static Handle<Code> initialize_stub_strict() { |
| 731 return Isolate::Current()->builtins()->builtin( | 756 return Isolate::Current()->builtins()->KeyedStoreIC_Initialize_Strict(); |
| 732 Builtins::kKeyedStoreIC_Initialize_Strict); | |
| 733 } | |
| 734 Handle<Code> megamorphic_stub() { | |
| 735 return isolate()->builtins()->KeyedStoreIC_Generic(); | |
| 736 } | |
| 737 Handle<Code> megamorphic_stub_strict() { | |
| 738 return isolate()->builtins()->KeyedStoreIC_Generic_Strict(); | |
| 739 } | 757 } |
| 740 Handle<Code> generic_stub() const { | 758 Handle<Code> generic_stub() const { |
| 741 return isolate()->builtins()->KeyedStoreIC_Generic(); | 759 return isolate()->builtins()->KeyedStoreIC_Generic(); |
| 742 } | 760 } |
| 743 Handle<Code> generic_stub_strict() const { | 761 Handle<Code> generic_stub_strict() const { |
| 744 return isolate()->builtins()->KeyedStoreIC_Generic_Strict(); | 762 return isolate()->builtins()->KeyedStoreIC_Generic_Strict(); |
| 745 } | 763 } |
| 746 Handle<Code> non_strict_arguments_stub() { | 764 Handle<Code> non_strict_arguments_stub() { |
| 747 return isolate()->builtins()->KeyedStoreIC_NonStrictArguments(); | 765 return isolate()->builtins()->KeyedStoreIC_NonStrictArguments(); |
| 748 } | 766 } |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 866 | 884 |
| 867 // Helper for BinaryOpIC and CompareIC. | 885 // Helper for BinaryOpIC and CompareIC. |
| 868 enum InlinedSmiCheck { ENABLE_INLINED_SMI_CHECK, DISABLE_INLINED_SMI_CHECK }; | 886 enum InlinedSmiCheck { ENABLE_INLINED_SMI_CHECK, DISABLE_INLINED_SMI_CHECK }; |
| 869 void PatchInlinedSmiCode(Address address, InlinedSmiCheck check); | 887 void PatchInlinedSmiCode(Address address, InlinedSmiCheck check); |
| 870 | 888 |
| 871 DECLARE_RUNTIME_FUNCTION(MaybeObject*, KeyedLoadIC_Miss); | 889 DECLARE_RUNTIME_FUNCTION(MaybeObject*, KeyedLoadIC_Miss); |
| 872 | 890 |
| 873 } } // namespace v8::internal | 891 } } // namespace v8::internal |
| 874 | 892 |
| 875 #endif // V8_IC_H_ | 893 #endif // V8_IC_H_ |
| OLD | NEW |