| 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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 Handle<Name> name, | 96 Handle<Name> name, |
| 97 Handle<HeapType> type, | 97 Handle<HeapType> type, |
| 98 Handle<Code> handler, | 98 Handle<Code> handler, |
| 99 ExtraICState extra_ic_state); | 99 ExtraICState extra_ic_state); |
| 100 | 100 |
| 101 Handle<Code> ComputeLoadNonexistent(Handle<Name> name, Handle<HeapType> type); | 101 Handle<Code> ComputeLoadNonexistent(Handle<Name> name, Handle<HeapType> type); |
| 102 | 102 |
| 103 Handle<Code> ComputeKeyedLoadElement(Handle<Map> receiver_map); | 103 Handle<Code> ComputeKeyedLoadElement(Handle<Map> receiver_map); |
| 104 | 104 |
| 105 Handle<Code> ComputeKeyedStoreElement(Handle<Map> receiver_map, | 105 Handle<Code> ComputeKeyedStoreElement(Handle<Map> receiver_map, |
| 106 StrictModeFlag strict_mode, | 106 StrictMode strict_mode, |
| 107 KeyedAccessStoreMode store_mode); | 107 KeyedAccessStoreMode store_mode); |
| 108 | 108 |
| 109 // --- | 109 // --- |
| 110 | 110 |
| 111 Handle<Code> ComputeLoad(InlineCacheState ic_state, ExtraICState extra_state); | 111 Handle<Code> ComputeLoad(InlineCacheState ic_state, ExtraICState extra_state); |
| 112 Handle<Code> ComputeStore(InlineCacheState ic_state, | 112 Handle<Code> ComputeStore(InlineCacheState ic_state, |
| 113 ExtraICState extra_state); | 113 ExtraICState extra_state); |
| 114 | 114 |
| 115 // --- | 115 // --- |
| 116 | 116 |
| 117 Handle<Code> ComputeCompareNil(Handle<Map> receiver_map, | 117 Handle<Code> ComputeCompareNil(Handle<Map> receiver_map, |
| 118 CompareNilICStub& stub); | 118 CompareNilICStub& stub); |
| 119 | 119 |
| 120 // --- | 120 // --- |
| 121 | 121 |
| 122 Handle<Code> ComputeLoadElementPolymorphic(MapHandleList* receiver_maps); | 122 Handle<Code> ComputeLoadElementPolymorphic(MapHandleList* receiver_maps); |
| 123 Handle<Code> ComputeStoreElementPolymorphic(MapHandleList* receiver_maps, | 123 Handle<Code> ComputeStoreElementPolymorphic(MapHandleList* receiver_maps, |
| 124 KeyedAccessStoreMode store_mode, | 124 KeyedAccessStoreMode store_mode, |
| 125 StrictModeFlag strict_mode); | 125 StrictMode strict_mode); |
| 126 | 126 |
| 127 Handle<Code> ComputePolymorphicIC(Code::Kind kind, | 127 Handle<Code> ComputePolymorphicIC(Code::Kind kind, |
| 128 TypeHandleList* types, | 128 TypeHandleList* types, |
| 129 CodeHandleList* handlers, | 129 CodeHandleList* handlers, |
| 130 int number_of_valid_maps, | 130 int number_of_valid_maps, |
| 131 Handle<Name> name, | 131 Handle<Name> name, |
| 132 ExtraICState extra_ic_state); | 132 ExtraICState extra_ic_state); |
| 133 | 133 |
| 134 // Finds the Code object stored in the Heap::non_monomorphic_cache(). | 134 // Finds the Code object stored in the Heap::non_monomorphic_cache(). |
| 135 Code* FindPreMonomorphicIC(Code::Kind kind, ExtraICState extra_ic_state); | 135 Code* FindPreMonomorphicIC(Code::Kind kind, ExtraICState extra_ic_state); |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 Register src, | 353 Register src, |
| 354 bool inobject, | 354 bool inobject, |
| 355 int index, | 355 int index, |
| 356 Representation representation); | 356 Representation representation); |
| 357 | 357 |
| 358 static void GenerateLoadArrayLength(MacroAssembler* masm, | 358 static void GenerateLoadArrayLength(MacroAssembler* masm, |
| 359 Register receiver, | 359 Register receiver, |
| 360 Register scratch, | 360 Register scratch, |
| 361 Label* miss_label); | 361 Label* miss_label); |
| 362 | 362 |
| 363 static void GenerateLoadStringLength(MacroAssembler* masm, | |
| 364 Register receiver, | |
| 365 Register scratch1, | |
| 366 Register scratch2, | |
| 367 Label* miss_label); | |
| 368 | |
| 369 static void GenerateLoadFunctionPrototype(MacroAssembler* masm, | 363 static void GenerateLoadFunctionPrototype(MacroAssembler* masm, |
| 370 Register receiver, | 364 Register receiver, |
| 371 Register scratch1, | 365 Register scratch1, |
| 372 Register scratch2, | 366 Register scratch2, |
| 373 Label* miss_label); | 367 Label* miss_label); |
| 374 | 368 |
| 375 // Generate code to check that a global property cell is empty. Create | 369 // Generate code to check that a global property cell is empty. Create |
| 376 // the property cell at compilation time if no cell exists for the | 370 // the property cell at compilation time if no cell exists for the |
| 377 // property. | 371 // property. |
| 378 static void GenerateCheckPropertyCell(MacroAssembler* masm, | 372 static void GenerateCheckPropertyCell(MacroAssembler* masm, |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 515 } else if (kind_ == Code::STORE_IC) { | 509 } else if (kind_ == Code::STORE_IC) { |
| 516 return code->ic_state() == MONOMORPHIC | 510 return code->ic_state() == MONOMORPHIC |
| 517 ? Logger::STORE_IC_TAG : Logger::STORE_POLYMORPHIC_IC_TAG; | 511 ? Logger::STORE_IC_TAG : Logger::STORE_POLYMORPHIC_IC_TAG; |
| 518 } else { | 512 } else { |
| 519 return code->ic_state() == MONOMORPHIC | 513 return code->ic_state() == MONOMORPHIC |
| 520 ? Logger::KEYED_STORE_IC_TAG : Logger::KEYED_STORE_POLYMORPHIC_IC_TAG; | 514 ? Logger::KEYED_STORE_IC_TAG : Logger::KEYED_STORE_POLYMORPHIC_IC_TAG; |
| 521 } | 515 } |
| 522 } | 516 } |
| 523 void JitEvent(Handle<Name> name, Handle<Code> code); | 517 void JitEvent(Handle<Name> name, Handle<Code> code); |
| 524 | 518 |
| 525 virtual Register receiver() = 0; | 519 Register receiver() { return registers_[0]; } |
| 526 virtual Register name() = 0; | 520 Register name() { return registers_[1]; } |
| 527 virtual Register scratch1() = 0; | 521 Register scratch1() { return registers_[2]; } |
| 528 virtual Register scratch2() = 0; | 522 Register scratch2() { return registers_[3]; } |
| 529 virtual Register scratch3() = 0; | 523 Register scratch3() { return registers_[4]; } |
| 530 | 524 |
| 531 void InitializeRegisters(); | 525 void InitializeRegisters(); |
| 532 | 526 |
| 533 bool IncludesNumberType(TypeHandleList* types); | 527 bool IncludesNumberType(TypeHandleList* types); |
| 534 | 528 |
| 535 Code::Kind kind_; | 529 Code::Kind kind_; |
| 536 InlineCacheHolderFlag cache_holder_; | 530 InlineCacheHolderFlag cache_holder_; |
| 537 Register* registers_; | 531 Register* registers_; |
| 538 }; | 532 }; |
| 539 | 533 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 576 Handle<Code> CompileLoadViaGetter(Handle<HeapType> type, | 570 Handle<Code> CompileLoadViaGetter(Handle<HeapType> type, |
| 577 Handle<JSObject> holder, | 571 Handle<JSObject> holder, |
| 578 Handle<Name> name, | 572 Handle<Name> name, |
| 579 Handle<JSFunction> getter); | 573 Handle<JSFunction> getter); |
| 580 | 574 |
| 581 static void GenerateLoadViaGetter(MacroAssembler* masm, | 575 static void GenerateLoadViaGetter(MacroAssembler* masm, |
| 582 Handle<HeapType> type, | 576 Handle<HeapType> type, |
| 583 Register receiver, | 577 Register receiver, |
| 584 Handle<JSFunction> getter); | 578 Handle<JSFunction> getter); |
| 585 | 579 |
| 580 static void GenerateLoadViaGetterForDeopt(MacroAssembler* masm) { |
| 581 GenerateLoadViaGetter( |
| 582 masm, Handle<HeapType>::null(), no_reg, Handle<JSFunction>()); |
| 583 } |
| 584 |
| 586 Handle<Code> CompileLoadNonexistent(Handle<HeapType> type, | 585 Handle<Code> CompileLoadNonexistent(Handle<HeapType> type, |
| 587 Handle<JSObject> last, | 586 Handle<JSObject> last, |
| 588 Handle<Name> name); | 587 Handle<Name> name); |
| 589 | 588 |
| 590 Handle<Code> CompileLoadGlobal(Handle<HeapType> type, | 589 Handle<Code> CompileLoadGlobal(Handle<HeapType> type, |
| 591 Handle<GlobalObject> holder, | 590 Handle<GlobalObject> holder, |
| 592 Handle<PropertyCell> cell, | 591 Handle<PropertyCell> cell, |
| 593 Handle<Name> name, | 592 Handle<Name> name, |
| 594 bool is_dont_delete); | 593 bool is_dont_delete); |
| 595 | 594 |
| 596 static Register* registers(); | |
| 597 | |
| 598 protected: | 595 protected: |
| 599 ContextualMode contextual_mode() { | 596 ContextualMode contextual_mode() { |
| 600 return LoadIC::GetContextualMode(extra_state()); | 597 return LoadIC::GetContextualMode(extra_state()); |
| 601 } | 598 } |
| 602 | 599 |
| 603 virtual Register HandlerFrontendHeader(Handle<HeapType> type, | 600 virtual Register HandlerFrontendHeader(Handle<HeapType> type, |
| 604 Register object_reg, | 601 Register object_reg, |
| 605 Handle<JSObject> holder, | 602 Handle<JSObject> holder, |
| 606 Handle<Name> name, | 603 Handle<Name> name, |
| 607 Label* miss); | 604 Label* miss); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 629 void GenerateLoadInterceptor(Register holder_reg, | 626 void GenerateLoadInterceptor(Register holder_reg, |
| 630 Handle<Object> object, | 627 Handle<Object> object, |
| 631 Handle<JSObject> holder, | 628 Handle<JSObject> holder, |
| 632 LookupResult* lookup, | 629 LookupResult* lookup, |
| 633 Handle<Name> name); | 630 Handle<Name> name); |
| 634 void GenerateLoadPostInterceptor(Register reg, | 631 void GenerateLoadPostInterceptor(Register reg, |
| 635 Handle<JSObject> interceptor_holder, | 632 Handle<JSObject> interceptor_holder, |
| 636 Handle<Name> name, | 633 Handle<Name> name, |
| 637 LookupResult* lookup); | 634 LookupResult* lookup); |
| 638 | 635 |
| 639 virtual Register receiver() { return registers_[0]; } | 636 private: |
| 640 virtual Register name() { return registers_[1]; } | 637 static Register* registers(); |
| 641 virtual Register scratch1() { return registers_[2]; } | |
| 642 virtual Register scratch2() { return registers_[3]; } | |
| 643 virtual Register scratch3() { return registers_[4]; } | |
| 644 Register scratch4() { return registers_[5]; } | 638 Register scratch4() { return registers_[5]; } |
| 639 friend class BaseLoadStoreStubCompiler; |
| 645 }; | 640 }; |
| 646 | 641 |
| 647 | 642 |
| 648 class KeyedLoadStubCompiler: public LoadStubCompiler { | 643 class KeyedLoadStubCompiler: public LoadStubCompiler { |
| 649 public: | 644 public: |
| 650 KeyedLoadStubCompiler(Isolate* isolate, | 645 KeyedLoadStubCompiler(Isolate* isolate, |
| 651 ExtraICState extra_ic_state = kNoExtraICState, | 646 ExtraICState extra_ic_state = kNoExtraICState, |
| 652 InlineCacheHolderFlag cache_holder = OWN_MAP) | 647 InlineCacheHolderFlag cache_holder = OWN_MAP) |
| 653 : LoadStubCompiler(isolate, extra_ic_state, cache_holder, | 648 : LoadStubCompiler(isolate, extra_ic_state, cache_holder, |
| 654 Code::KEYED_LOAD_IC) { } | 649 Code::KEYED_LOAD_IC) { } |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 719 Handle<Name> name, | 714 Handle<Name> name, |
| 720 Handle<ExecutableAccessorInfo> callback); | 715 Handle<ExecutableAccessorInfo> callback); |
| 721 | 716 |
| 722 Handle<Code> CompileStoreCallback(Handle<JSObject> object, | 717 Handle<Code> CompileStoreCallback(Handle<JSObject> object, |
| 723 Handle<JSObject> holder, | 718 Handle<JSObject> holder, |
| 724 Handle<Name> name, | 719 Handle<Name> name, |
| 725 const CallOptimization& call_optimization); | 720 const CallOptimization& call_optimization); |
| 726 | 721 |
| 727 static void GenerateStoreViaSetter(MacroAssembler* masm, | 722 static void GenerateStoreViaSetter(MacroAssembler* masm, |
| 728 Handle<HeapType> type, | 723 Handle<HeapType> type, |
| 724 Register receiver, |
| 729 Handle<JSFunction> setter); | 725 Handle<JSFunction> setter); |
| 730 | 726 |
| 727 static void GenerateStoreViaSetterForDeopt(MacroAssembler* masm) { |
| 728 GenerateStoreViaSetter( |
| 729 masm, Handle<HeapType>::null(), no_reg, Handle<JSFunction>()); |
| 730 } |
| 731 |
| 731 Handle<Code> CompileStoreViaSetter(Handle<JSObject> object, | 732 Handle<Code> CompileStoreViaSetter(Handle<JSObject> object, |
| 732 Handle<JSObject> holder, | 733 Handle<JSObject> holder, |
| 733 Handle<Name> name, | 734 Handle<Name> name, |
| 734 Handle<JSFunction> setter); | 735 Handle<JSFunction> setter); |
| 735 | 736 |
| 736 Handle<Code> CompileStoreInterceptor(Handle<JSObject> object, | 737 Handle<Code> CompileStoreInterceptor(Handle<JSObject> object, |
| 737 Handle<Name> name); | 738 Handle<Name> name); |
| 738 | 739 |
| 739 static Builtins::Name SlowBuiltin(Code::Kind kind) { | 740 static Builtins::Name SlowBuiltin(Code::Kind kind) { |
| 740 switch (kind) { | 741 switch (kind) { |
| 741 case Code::STORE_IC: return Builtins::kStoreIC_Slow; | 742 case Code::STORE_IC: return Builtins::kStoreIC_Slow; |
| 742 case Code::KEYED_STORE_IC: return Builtins::kKeyedStoreIC_Slow; | 743 case Code::KEYED_STORE_IC: return Builtins::kKeyedStoreIC_Slow; |
| 743 default: UNREACHABLE(); | 744 default: UNREACHABLE(); |
| 744 } | 745 } |
| 745 return Builtins::kStoreIC_Slow; | 746 return Builtins::kStoreIC_Slow; |
| 746 } | 747 } |
| 747 | 748 |
| 748 protected: | 749 protected: |
| 749 virtual Register HandlerFrontendHeader(Handle<HeapType> type, | 750 virtual Register HandlerFrontendHeader(Handle<HeapType> type, |
| 750 Register object_reg, | 751 Register object_reg, |
| 751 Handle<JSObject> holder, | 752 Handle<JSObject> holder, |
| 752 Handle<Name> name, | 753 Handle<Name> name, |
| 753 Label* miss); | 754 Label* miss); |
| 754 | 755 |
| 755 virtual void HandlerFrontendFooter(Handle<Name> name, Label* miss); | 756 virtual void HandlerFrontendFooter(Handle<Name> name, Label* miss); |
| 756 void GenerateRestoreName(MacroAssembler* masm, | 757 void GenerateRestoreName(MacroAssembler* masm, |
| 757 Label* label, | 758 Label* label, |
| 758 Handle<Name> name); | 759 Handle<Name> name); |
| 759 | 760 |
| 760 virtual Register receiver() { return registers_[0]; } | 761 private: |
| 761 virtual Register name() { return registers_[1]; } | |
| 762 Register value() { return registers_[2]; } | |
| 763 virtual Register scratch1() { return registers_[3]; } | |
| 764 virtual Register scratch2() { return registers_[4]; } | |
| 765 virtual Register scratch3() { return registers_[5]; } | |
| 766 | |
| 767 protected: | |
| 768 static Register* registers(); | 762 static Register* registers(); |
| 769 | 763 static Register value(); |
| 770 private: | |
| 771 friend class BaseLoadStoreStubCompiler; | 764 friend class BaseLoadStoreStubCompiler; |
| 772 }; | 765 }; |
| 773 | 766 |
| 774 | 767 |
| 775 class KeyedStoreStubCompiler: public StoreStubCompiler { | 768 class KeyedStoreStubCompiler: public StoreStubCompiler { |
| 776 public: | 769 public: |
| 777 KeyedStoreStubCompiler(Isolate* isolate, | 770 KeyedStoreStubCompiler(Isolate* isolate, |
| 778 ExtraICState extra_ic_state) | 771 ExtraICState extra_ic_state) |
| 779 : StoreStubCompiler(isolate, extra_ic_state, Code::KEYED_STORE_IC) {} | 772 : StoreStubCompiler(isolate, extra_ic_state, Code::KEYED_STORE_IC) {} |
| 780 | 773 |
| 781 Handle<Code> CompileStoreElement(Handle<Map> receiver_map); | 774 Handle<Code> CompileStoreElement(Handle<Map> receiver_map); |
| 782 | 775 |
| 783 Handle<Code> CompileStorePolymorphic(MapHandleList* receiver_maps, | 776 Handle<Code> CompileStorePolymorphic(MapHandleList* receiver_maps, |
| 784 CodeHandleList* handler_stubs, | 777 CodeHandleList* handler_stubs, |
| 785 MapHandleList* transitioned_maps); | 778 MapHandleList* transitioned_maps); |
| 786 | 779 |
| 787 Handle<Code> CompileStoreElementPolymorphic(MapHandleList* receiver_maps); | 780 Handle<Code> CompileStoreElementPolymorphic(MapHandleList* receiver_maps); |
| 788 | 781 |
| 789 static void GenerateStoreDictionaryElement(MacroAssembler* masm); | 782 static void GenerateStoreDictionaryElement(MacroAssembler* masm); |
| 790 | 783 |
| 791 private: | 784 private: |
| 792 static Register* registers(); | 785 static Register* registers(); |
| 793 | 786 |
| 794 KeyedAccessStoreMode store_mode() { | 787 KeyedAccessStoreMode store_mode() { |
| 795 return KeyedStoreIC::GetKeyedAccessStoreMode(extra_state()); | 788 return KeyedStoreIC::GetKeyedAccessStoreMode(extra_state()); |
| 796 } | 789 } |
| 797 | 790 |
| 798 Register transition_map() { | 791 Register transition_map() { return scratch1(); } |
| 799 return registers()[3]; | |
| 800 } | |
| 801 | 792 |
| 802 friend class BaseLoadStoreStubCompiler; | 793 friend class BaseLoadStoreStubCompiler; |
| 803 }; | 794 }; |
| 804 | 795 |
| 805 | 796 |
| 806 // Holds information about possible function call optimizations. | 797 // Holds information about possible function call optimizations. |
| 807 class CallOptimization BASE_EMBEDDED { | 798 class CallOptimization BASE_EMBEDDED { |
| 808 public: | 799 public: |
| 809 explicit CallOptimization(LookupResult* lookup); | 800 explicit CallOptimization(LookupResult* lookup); |
| 810 | 801 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 856 Handle<JSFunction> constant_function_; | 847 Handle<JSFunction> constant_function_; |
| 857 bool is_simple_api_call_; | 848 bool is_simple_api_call_; |
| 858 Handle<FunctionTemplateInfo> expected_receiver_type_; | 849 Handle<FunctionTemplateInfo> expected_receiver_type_; |
| 859 Handle<CallHandlerInfo> api_call_info_; | 850 Handle<CallHandlerInfo> api_call_info_; |
| 860 }; | 851 }; |
| 861 | 852 |
| 862 | 853 |
| 863 } } // namespace v8::internal | 854 } } // namespace v8::internal |
| 864 | 855 |
| 865 #endif // V8_STUB_CACHE_H_ | 856 #endif // V8_STUB_CACHE_H_ |
| OLD | NEW |