| 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 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 577 | 577 |
| 578 | 578 |
| 579 enum KeyedStoreIncrementLength { | 579 enum KeyedStoreIncrementLength { |
| 580 kDontIncrementLength, | 580 kDontIncrementLength, |
| 581 kIncrementLength | 581 kIncrementLength |
| 582 }; | 582 }; |
| 583 | 583 |
| 584 | 584 |
| 585 class KeyedStoreIC: public StoreIC { | 585 class KeyedStoreIC: public StoreIC { |
| 586 public: | 586 public: |
| 587 enum StubKind { | |
| 588 STORE_NO_TRANSITION, | |
| 589 STORE_TRANSITION_SMI_TO_OBJECT, | |
| 590 STORE_TRANSITION_SMI_TO_DOUBLE, | |
| 591 STORE_TRANSITION_DOUBLE_TO_OBJECT, | |
| 592 STORE_TRANSITION_HOLEY_SMI_TO_OBJECT, | |
| 593 STORE_TRANSITION_HOLEY_SMI_TO_DOUBLE, | |
| 594 STORE_TRANSITION_HOLEY_DOUBLE_TO_OBJECT, | |
| 595 STORE_AND_GROW_NO_TRANSITION, | |
| 596 STORE_AND_GROW_TRANSITION_SMI_TO_OBJECT, | |
| 597 STORE_AND_GROW_TRANSITION_SMI_TO_DOUBLE, | |
| 598 STORE_AND_GROW_TRANSITION_DOUBLE_TO_OBJECT, | |
| 599 STORE_AND_GROW_TRANSITION_HOLEY_SMI_TO_OBJECT, | |
| 600 STORE_AND_GROW_TRANSITION_HOLEY_SMI_TO_DOUBLE, | |
| 601 STORE_AND_GROW_TRANSITION_HOLEY_DOUBLE_TO_OBJECT | |
| 602 }; | |
| 603 | |
| 604 static const int kGrowICDelta = STORE_AND_GROW_NO_TRANSITION - | |
| 605 STORE_NO_TRANSITION; | |
| 606 STATIC_ASSERT(kGrowICDelta == | |
| 607 STORE_AND_GROW_TRANSITION_SMI_TO_OBJECT - | |
| 608 STORE_TRANSITION_SMI_TO_OBJECT); | |
| 609 STATIC_ASSERT(kGrowICDelta == | |
| 610 STORE_AND_GROW_TRANSITION_SMI_TO_DOUBLE - | |
| 611 STORE_TRANSITION_SMI_TO_DOUBLE); | |
| 612 STATIC_ASSERT(kGrowICDelta == | |
| 613 STORE_AND_GROW_TRANSITION_DOUBLE_TO_OBJECT - | |
| 614 STORE_TRANSITION_DOUBLE_TO_OBJECT); | |
| 615 | |
| 616 static inline StubKind GetGrowStubKind(StubKind stub_kind) { | |
| 617 if (stub_kind < STORE_AND_GROW_NO_TRANSITION) { | |
| 618 stub_kind = static_cast<StubKind>(static_cast<int>(stub_kind) + | |
| 619 kGrowICDelta); | |
| 620 } | |
| 621 return stub_kind; | |
| 622 } | |
| 623 | |
| 624 explicit KeyedStoreIC(Isolate* isolate) : StoreIC(isolate) { | 587 explicit KeyedStoreIC(Isolate* isolate) : StoreIC(isolate) { |
| 625 ASSERT(target()->is_keyed_store_stub()); | 588 ASSERT(target()->is_keyed_store_stub()); |
| 626 } | 589 } |
| 627 | 590 |
| 628 MUST_USE_RESULT MaybeObject* Store(State state, | 591 MUST_USE_RESULT MaybeObject* Store(State state, |
| 629 StrictModeFlag strict_mode, | 592 StrictModeFlag strict_mode, |
| 630 Handle<Object> object, | 593 Handle<Object> object, |
| 631 Handle<Object> name, | 594 Handle<Object> name, |
| 632 Handle<Object> value, | 595 Handle<Object> value, |
| 633 ICMissMode force_generic); | 596 ICMissMode force_generic); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 655 virtual void UpdateMegamorphicCache(Map* map, String* name, Code* code) { } | 618 virtual void UpdateMegamorphicCache(Map* map, String* name, Code* code) { } |
| 656 | 619 |
| 657 virtual Handle<Code> megamorphic_stub() { | 620 virtual Handle<Code> megamorphic_stub() { |
| 658 return isolate()->builtins()->KeyedStoreIC_Generic(); | 621 return isolate()->builtins()->KeyedStoreIC_Generic(); |
| 659 } | 622 } |
| 660 virtual Handle<Code> megamorphic_stub_strict() { | 623 virtual Handle<Code> megamorphic_stub_strict() { |
| 661 return isolate()->builtins()->KeyedStoreIC_Generic_Strict(); | 624 return isolate()->builtins()->KeyedStoreIC_Generic_Strict(); |
| 662 } | 625 } |
| 663 | 626 |
| 664 Handle<Code> StoreElementStub(Handle<JSObject> receiver, | 627 Handle<Code> StoreElementStub(Handle<JSObject> receiver, |
| 665 StubKind stub_kind, | 628 KeyedAccessStoreMode store_mode, |
| 666 StrictModeFlag strict_mode); | 629 StrictModeFlag strict_mode); |
| 667 | 630 |
| 668 private: | 631 private: |
| 669 void set_target(Code* code) { | 632 void set_target(Code* code) { |
| 670 // Strict mode must be preserved across IC patching. | 633 // Strict mode must be preserved across IC patching. |
| 671 ASSERT(Code::GetStrictMode(code->extra_ic_state()) == | 634 ASSERT(Code::GetStrictMode(code->extra_ic_state()) == |
| 672 Code::GetStrictMode(target()->extra_ic_state())); | 635 Code::GetStrictMode(target()->extra_ic_state())); |
| 673 IC::set_target(code); | 636 IC::set_target(code); |
| 674 } | 637 } |
| 675 | 638 |
| 676 // Stub accessors. | 639 // Stub accessors. |
| 677 static Handle<Code> initialize_stub() { | 640 static Handle<Code> initialize_stub() { |
| 678 return Isolate::Current()->builtins()->KeyedStoreIC_Initialize(); | 641 return Isolate::Current()->builtins()->KeyedStoreIC_Initialize(); |
| 679 } | 642 } |
| 680 static Handle<Code> initialize_stub_strict() { | 643 static Handle<Code> initialize_stub_strict() { |
| 681 return Isolate::Current()->builtins()->KeyedStoreIC_Initialize_Strict(); | 644 return Isolate::Current()->builtins()->KeyedStoreIC_Initialize_Strict(); |
| 682 } | 645 } |
| 683 Handle<Code> generic_stub() const { | 646 Handle<Code> generic_stub() const { |
| 684 return isolate()->builtins()->KeyedStoreIC_Generic(); | 647 return isolate()->builtins()->KeyedStoreIC_Generic(); |
| 685 } | 648 } |
| 686 Handle<Code> generic_stub_strict() const { | 649 Handle<Code> generic_stub_strict() const { |
| 687 return isolate()->builtins()->KeyedStoreIC_Generic_Strict(); | 650 return isolate()->builtins()->KeyedStoreIC_Generic_Strict(); |
| 688 } | 651 } |
| 689 Handle<Code> non_strict_arguments_stub() { | 652 Handle<Code> non_strict_arguments_stub() { |
| 690 return isolate()->builtins()->KeyedStoreIC_NonStrictArguments(); | 653 return isolate()->builtins()->KeyedStoreIC_NonStrictArguments(); |
| 691 } | 654 } |
| 692 | 655 |
| 693 static void Clear(Address address, Code* target); | 656 static void Clear(Address address, Code* target); |
| 694 | 657 |
| 695 StubKind GetStubKind(Handle<JSObject> receiver, | 658 KeyedAccessStoreMode GetStoreMode(Handle<JSObject> receiver, |
| 696 Handle<Object> key, | 659 Handle<Object> key, |
| 697 Handle<Object> value); | 660 Handle<Object> value); |
| 698 | |
| 699 static bool IsTransitionStubKind(StubKind stub_kind) { | |
| 700 return stub_kind > STORE_NO_TRANSITION && | |
| 701 stub_kind != STORE_AND_GROW_NO_TRANSITION; | |
| 702 } | |
| 703 | |
| 704 static bool IsGrowStubKind(StubKind stub_kind) { | |
| 705 return stub_kind >= STORE_AND_GROW_NO_TRANSITION; | |
| 706 } | |
| 707 | |
| 708 static StubKind GetNoTransitionStubKind(StubKind stub_kind) { | |
| 709 if (!IsTransitionStubKind(stub_kind)) return stub_kind; | |
| 710 if (IsGrowStubKind(stub_kind)) return STORE_AND_GROW_NO_TRANSITION; | |
| 711 return STORE_NO_TRANSITION; | |
| 712 } | |
| 713 | 661 |
| 714 Handle<Map> ComputeTransitionedMap(Handle<JSObject> receiver, | 662 Handle<Map> ComputeTransitionedMap(Handle<JSObject> receiver, |
| 715 StubKind stub_kind); | 663 KeyedAccessStoreMode store_mode); |
| 716 | 664 |
| 717 friend class IC; | 665 friend class IC; |
| 718 }; | 666 }; |
| 719 | 667 |
| 720 | 668 |
| 721 class UnaryOpIC: public IC { | 669 class UnaryOpIC: public IC { |
| 722 public: | 670 public: |
| 723 // sorted: increasingly more unspecific (ignoring UNINITIALIZED) | 671 // sorted: increasingly more unspecific (ignoring UNINITIALIZED) |
| 724 // TODO(svenpanne) Using enums+switch is an antipattern, use a class instead. | 672 // TODO(svenpanne) Using enums+switch is an antipattern, use a class instead. |
| 725 enum TypeInfo { | 673 enum TypeInfo { |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 829 explicit ToBooleanIC(Isolate* isolate) : IC(NO_EXTRA_FRAME, isolate) { } | 777 explicit ToBooleanIC(Isolate* isolate) : IC(NO_EXTRA_FRAME, isolate) { } |
| 830 | 778 |
| 831 void patch(Code* code); | 779 void patch(Code* code); |
| 832 }; | 780 }; |
| 833 | 781 |
| 834 | 782 |
| 835 // Helper for BinaryOpIC and CompareIC. | 783 // Helper for BinaryOpIC and CompareIC. |
| 836 enum InlinedSmiCheck { ENABLE_INLINED_SMI_CHECK, DISABLE_INLINED_SMI_CHECK }; | 784 enum InlinedSmiCheck { ENABLE_INLINED_SMI_CHECK, DISABLE_INLINED_SMI_CHECK }; |
| 837 void PatchInlinedSmiCode(Address address, InlinedSmiCheck check); | 785 void PatchInlinedSmiCode(Address address, InlinedSmiCheck check); |
| 838 | 786 |
| 839 DECLARE_RUNTIME_FUNCTION(MaybeObject*, KeyedLoadIC_Miss); | |
| 840 DECLARE_RUNTIME_FUNCTION(MaybeObject*, KeyedLoadIC_MissFromStubFailure); | 787 DECLARE_RUNTIME_FUNCTION(MaybeObject*, KeyedLoadIC_MissFromStubFailure); |
| 841 | 788 |
| 842 } } // namespace v8::internal | 789 } } // namespace v8::internal |
| 843 | 790 |
| 844 #endif // V8_IC_H_ | 791 #endif // V8_IC_H_ |
| OLD | NEW |