| 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 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 585 template <typename ElementsAccessorSubclass, | 585 template <typename ElementsAccessorSubclass, |
| 586 typename ElementsTraitsParam> | 586 typename ElementsTraitsParam> |
| 587 class ElementsAccessorBase : public ElementsAccessor { | 587 class ElementsAccessorBase : public ElementsAccessor { |
| 588 protected: | 588 protected: |
| 589 explicit ElementsAccessorBase(const char* name) | 589 explicit ElementsAccessorBase(const char* name) |
| 590 : ElementsAccessor(name) { } | 590 : ElementsAccessor(name) { } |
| 591 | 591 |
| 592 typedef ElementsTraitsParam ElementsTraits; | 592 typedef ElementsTraitsParam ElementsTraits; |
| 593 typedef typename ElementsTraitsParam::BackingStore BackingStore; | 593 typedef typename ElementsTraitsParam::BackingStore BackingStore; |
| 594 | 594 |
| 595 virtual ElementsKind kind() const { return ElementsTraits::Kind; } | 595 virtual ElementsKind kind() const V8_FINAL V8_OVERRIDE { |
| 596 return ElementsTraits::Kind; |
| 597 } |
| 596 | 598 |
| 597 static void ValidateContents(JSObject* holder, int length) { | 599 static void ValidateContents(JSObject* holder, int length) { |
| 598 } | 600 } |
| 599 | 601 |
| 600 static void ValidateImpl(JSObject* holder) { | 602 static void ValidateImpl(JSObject* holder) { |
| 601 FixedArrayBase* fixed_array_base = holder->elements(); | 603 FixedArrayBase* fixed_array_base = holder->elements(); |
| 602 // When objects are first allocated, its elements are Failures. | 604 // When objects are first allocated, its elements are Failures. |
| 603 if (fixed_array_base->IsFailure()) return; | 605 if (fixed_array_base->IsFailure()) return; |
| 604 if (!fixed_array_base->IsHeapObject()) return; | 606 if (!fixed_array_base->IsHeapObject()) return; |
| 605 // Arrays that have been shifted in place can't be verified. | 607 // Arrays that have been shifted in place can't be verified. |
| 606 if (fixed_array_base->IsFiller()) return; | 608 if (fixed_array_base->IsFiller()) return; |
| 607 int length = 0; | 609 int length = 0; |
| 608 if (holder->IsJSArray()) { | 610 if (holder->IsJSArray()) { |
| 609 Object* length_obj = JSArray::cast(holder)->length(); | 611 Object* length_obj = JSArray::cast(holder)->length(); |
| 610 if (length_obj->IsSmi()) { | 612 if (length_obj->IsSmi()) { |
| 611 length = Smi::cast(length_obj)->value(); | 613 length = Smi::cast(length_obj)->value(); |
| 612 } | 614 } |
| 613 } else { | 615 } else { |
| 614 length = fixed_array_base->length(); | 616 length = fixed_array_base->length(); |
| 615 } | 617 } |
| 616 ElementsAccessorSubclass::ValidateContents(holder, length); | 618 ElementsAccessorSubclass::ValidateContents(holder, length); |
| 617 } | 619 } |
| 618 | 620 |
| 619 virtual void Validate(JSObject* holder) { | 621 virtual void Validate(JSObject* holder) V8_FINAL V8_OVERRIDE { |
| 620 ElementsAccessorSubclass::ValidateImpl(holder); | 622 ElementsAccessorSubclass::ValidateImpl(holder); |
| 621 } | 623 } |
| 622 | 624 |
| 623 static bool HasElementImpl(Object* receiver, | 625 static bool HasElementImpl(Object* receiver, |
| 624 JSObject* holder, | 626 JSObject* holder, |
| 625 uint32_t key, | 627 uint32_t key, |
| 626 FixedArrayBase* backing_store) { | 628 FixedArrayBase* backing_store) { |
| 627 return ElementsAccessorSubclass::GetAttributesImpl( | 629 return ElementsAccessorSubclass::GetAttributesImpl( |
| 628 receiver, holder, key, backing_store) != ABSENT; | 630 receiver, holder, key, backing_store) != ABSENT; |
| 629 } | 631 } |
| 630 | 632 |
| 631 virtual bool HasElement(Object* receiver, | 633 virtual bool HasElement(Object* receiver, |
| 632 JSObject* holder, | 634 JSObject* holder, |
| 633 uint32_t key, | 635 uint32_t key, |
| 634 FixedArrayBase* backing_store) { | 636 FixedArrayBase* backing_store) V8_FINAL V8_OVERRIDE { |
| 635 if (backing_store == NULL) { | 637 if (backing_store == NULL) { |
| 636 backing_store = holder->elements(); | 638 backing_store = holder->elements(); |
| 637 } | 639 } |
| 638 return ElementsAccessorSubclass::HasElementImpl( | 640 return ElementsAccessorSubclass::HasElementImpl( |
| 639 receiver, holder, key, backing_store); | 641 receiver, holder, key, backing_store); |
| 640 } | 642 } |
| 641 | 643 |
| 642 // TODO(ishell): Temporary wrapper until handlified. | 644 // TODO(ishell): Temporary wrapper until handlified. |
| 643 MUST_USE_RESULT virtual Handle<Object> Get( | 645 MUST_USE_RESULT virtual Handle<Object> Get( |
| 644 Handle<Object> receiver, | 646 Handle<Object> receiver, |
| 645 Handle<JSObject> holder, | 647 Handle<JSObject> holder, |
| 646 uint32_t key, | 648 uint32_t key, |
| 647 Handle<FixedArrayBase> backing_store) { | 649 Handle<FixedArrayBase> backing_store) V8_FINAL V8_OVERRIDE { |
| 648 CALL_HEAP_FUNCTION(holder->GetIsolate(), | 650 CALL_HEAP_FUNCTION(holder->GetIsolate(), |
| 649 Get(*receiver, *holder, key, | 651 Get(*receiver, *holder, key, |
| 650 backing_store.is_null() | 652 backing_store.is_null() |
| 651 ? NULL : *backing_store), | 653 ? NULL : *backing_store), |
| 652 Object); | 654 Object); |
| 653 } | 655 } |
| 654 | 656 |
| 655 MUST_USE_RESULT virtual MaybeObject* Get(Object* receiver, | 657 MUST_USE_RESULT virtual MaybeObject* Get( |
| 656 JSObject* holder, | 658 Object* receiver, |
| 657 uint32_t key, | 659 JSObject* holder, |
| 658 FixedArrayBase* backing_store) { | 660 uint32_t key, |
| 661 FixedArrayBase* backing_store) V8_FINAL V8_OVERRIDE { |
| 659 if (backing_store == NULL) { | 662 if (backing_store == NULL) { |
| 660 backing_store = holder->elements(); | 663 backing_store = holder->elements(); |
| 661 } | 664 } |
| 662 | 665 |
| 663 if (!IsExternalArrayElementsKind(ElementsTraits::Kind) && | 666 if (!IsExternalArrayElementsKind(ElementsTraits::Kind) && |
| 664 FLAG_trace_js_array_abuse) { | 667 FLAG_trace_js_array_abuse) { |
| 665 CheckArrayAbuse(holder, "elements read", key); | 668 CheckArrayAbuse(holder, "elements read", key); |
| 666 } | 669 } |
| 667 | 670 |
| 668 if (IsExternalArrayElementsKind(ElementsTraits::Kind) && | 671 if (IsExternalArrayElementsKind(ElementsTraits::Kind) && |
| (...skipping 11 matching lines...) Expand all Loading... |
| 680 FixedArrayBase* backing_store) { | 683 FixedArrayBase* backing_store) { |
| 681 return (key < ElementsAccessorSubclass::GetCapacityImpl(backing_store)) | 684 return (key < ElementsAccessorSubclass::GetCapacityImpl(backing_store)) |
| 682 ? BackingStore::cast(backing_store)->get(key) | 685 ? BackingStore::cast(backing_store)->get(key) |
| 683 : backing_store->GetHeap()->the_hole_value(); | 686 : backing_store->GetHeap()->the_hole_value(); |
| 684 } | 687 } |
| 685 | 688 |
| 686 MUST_USE_RESULT virtual PropertyAttributes GetAttributes( | 689 MUST_USE_RESULT virtual PropertyAttributes GetAttributes( |
| 687 Object* receiver, | 690 Object* receiver, |
| 688 JSObject* holder, | 691 JSObject* holder, |
| 689 uint32_t key, | 692 uint32_t key, |
| 690 FixedArrayBase* backing_store) { | 693 FixedArrayBase* backing_store) V8_FINAL V8_OVERRIDE { |
| 691 if (backing_store == NULL) { | 694 if (backing_store == NULL) { |
| 692 backing_store = holder->elements(); | 695 backing_store = holder->elements(); |
| 693 } | 696 } |
| 694 return ElementsAccessorSubclass::GetAttributesImpl( | 697 return ElementsAccessorSubclass::GetAttributesImpl( |
| 695 receiver, holder, key, backing_store); | 698 receiver, holder, key, backing_store); |
| 696 } | 699 } |
| 697 | 700 |
| 698 MUST_USE_RESULT static PropertyAttributes GetAttributesImpl( | 701 MUST_USE_RESULT static PropertyAttributes GetAttributesImpl( |
| 699 Object* receiver, | 702 Object* receiver, |
| 700 JSObject* obj, | 703 JSObject* obj, |
| 701 uint32_t key, | 704 uint32_t key, |
| 702 FixedArrayBase* backing_store) { | 705 FixedArrayBase* backing_store) { |
| 703 if (key >= ElementsAccessorSubclass::GetCapacityImpl(backing_store)) { | 706 if (key >= ElementsAccessorSubclass::GetCapacityImpl(backing_store)) { |
| 704 return ABSENT; | 707 return ABSENT; |
| 705 } | 708 } |
| 706 return BackingStore::cast(backing_store)->is_the_hole(key) ? ABSENT : NONE; | 709 return BackingStore::cast(backing_store)->is_the_hole(key) ? ABSENT : NONE; |
| 707 } | 710 } |
| 708 | 711 |
| 709 MUST_USE_RESULT virtual PropertyType GetType( | 712 MUST_USE_RESULT virtual PropertyType GetType( |
| 710 Object* receiver, | 713 Object* receiver, |
| 711 JSObject* holder, | 714 JSObject* holder, |
| 712 uint32_t key, | 715 uint32_t key, |
| 713 FixedArrayBase* backing_store) { | 716 FixedArrayBase* backing_store) V8_FINAL V8_OVERRIDE { |
| 714 if (backing_store == NULL) { | 717 if (backing_store == NULL) { |
| 715 backing_store = holder->elements(); | 718 backing_store = holder->elements(); |
| 716 } | 719 } |
| 717 return ElementsAccessorSubclass::GetTypeImpl( | 720 return ElementsAccessorSubclass::GetTypeImpl( |
| 718 receiver, holder, key, backing_store); | 721 receiver, holder, key, backing_store); |
| 719 } | 722 } |
| 720 | 723 |
| 721 MUST_USE_RESULT static PropertyType GetTypeImpl( | 724 MUST_USE_RESULT static PropertyType GetTypeImpl( |
| 722 Object* receiver, | 725 Object* receiver, |
| 723 JSObject* obj, | 726 JSObject* obj, |
| 724 uint32_t key, | 727 uint32_t key, |
| 725 FixedArrayBase* backing_store) { | 728 FixedArrayBase* backing_store) { |
| 726 if (key >= ElementsAccessorSubclass::GetCapacityImpl(backing_store)) { | 729 if (key >= ElementsAccessorSubclass::GetCapacityImpl(backing_store)) { |
| 727 return NONEXISTENT; | 730 return NONEXISTENT; |
| 728 } | 731 } |
| 729 return BackingStore::cast(backing_store)->is_the_hole(key) | 732 return BackingStore::cast(backing_store)->is_the_hole(key) |
| 730 ? NONEXISTENT : FIELD; | 733 ? NONEXISTENT : FIELD; |
| 731 } | 734 } |
| 732 | 735 |
| 733 MUST_USE_RESULT virtual AccessorPair* GetAccessorPair( | 736 MUST_USE_RESULT virtual AccessorPair* GetAccessorPair( |
| 734 Object* receiver, | 737 Object* receiver, |
| 735 JSObject* holder, | 738 JSObject* holder, |
| 736 uint32_t key, | 739 uint32_t key, |
| 737 FixedArrayBase* backing_store) { | 740 FixedArrayBase* backing_store) V8_FINAL V8_OVERRIDE { |
| 738 if (backing_store == NULL) { | 741 if (backing_store == NULL) { |
| 739 backing_store = holder->elements(); | 742 backing_store = holder->elements(); |
| 740 } | 743 } |
| 741 return ElementsAccessorSubclass::GetAccessorPairImpl( | 744 return ElementsAccessorSubclass::GetAccessorPairImpl( |
| 742 receiver, holder, key, backing_store); | 745 receiver, holder, key, backing_store); |
| 743 } | 746 } |
| 744 | 747 |
| 745 MUST_USE_RESULT static AccessorPair* GetAccessorPairImpl( | 748 MUST_USE_RESULT static AccessorPair* GetAccessorPairImpl( |
| 746 Object* receiver, | 749 Object* receiver, |
| 747 JSObject* obj, | 750 JSObject* obj, |
| 748 uint32_t key, | 751 uint32_t key, |
| 749 FixedArrayBase* backing_store) { | 752 FixedArrayBase* backing_store) { |
| 750 return NULL; | 753 return NULL; |
| 751 } | 754 } |
| 752 | 755 |
| 753 MUST_USE_RESULT virtual Handle<Object> SetLength( | 756 MUST_USE_RESULT virtual Handle<Object> SetLength( |
| 754 Handle<JSArray> array, | 757 Handle<JSArray> array, |
| 755 Handle<Object> length) { | 758 Handle<Object> length) V8_FINAL V8_OVERRIDE { |
| 756 Isolate* isolate = array->GetIsolate(); | 759 Isolate* isolate = array->GetIsolate(); |
| 757 return ElementsAccessorSubclass::SetLengthImpl( | 760 return ElementsAccessorSubclass::SetLengthImpl( |
| 758 array, length, handle(array->elements(), isolate)); | 761 array, length, handle(array->elements(), isolate)); |
| 759 } | 762 } |
| 760 | 763 |
| 761 MUST_USE_RESULT static Handle<Object> SetLengthImpl( | 764 MUST_USE_RESULT static Handle<Object> SetLengthImpl( |
| 762 Handle<JSObject> obj, | 765 Handle<JSObject> obj, |
| 763 Handle<Object> length, | 766 Handle<Object> length, |
| 764 Handle<FixedArrayBase> backing_store); | 767 Handle<FixedArrayBase> backing_store); |
| 765 | 768 |
| 766 MUST_USE_RESULT virtual MaybeObject* SetCapacityAndLength( | 769 MUST_USE_RESULT virtual MaybeObject* SetCapacityAndLength( |
| 767 JSArray* array, | 770 JSArray* array, |
| 768 int capacity, | 771 int capacity, |
| 769 int length) { | 772 int length) V8_FINAL V8_OVERRIDE { |
| 770 return ElementsAccessorSubclass::SetFastElementsCapacityAndLength( | 773 return ElementsAccessorSubclass::SetFastElementsCapacityAndLength( |
| 771 array, | 774 array, |
| 772 capacity, | 775 capacity, |
| 773 length); | 776 length); |
| 774 } | 777 } |
| 775 | 778 |
| 776 MUST_USE_RESULT static MaybeObject* SetFastElementsCapacityAndLength( | 779 MUST_USE_RESULT static MaybeObject* SetFastElementsCapacityAndLength( |
| 777 JSObject* obj, | 780 JSObject* obj, |
| 778 int capacity, | 781 int capacity, |
| 779 int length) { | 782 int length) { |
| 780 UNIMPLEMENTED(); | 783 UNIMPLEMENTED(); |
| 781 return obj; | 784 return obj; |
| 782 } | 785 } |
| 783 | 786 |
| 784 MUST_USE_RESULT virtual Handle<Object> Delete( | 787 MUST_USE_RESULT virtual Handle<Object> Delete( |
| 785 Handle<JSObject> obj, | 788 Handle<JSObject> obj, |
| 786 uint32_t key, | 789 uint32_t key, |
| 787 JSReceiver::DeleteMode mode) = 0; | 790 JSReceiver::DeleteMode mode) V8_OVERRIDE = 0; |
| 788 | 791 |
| 789 MUST_USE_RESULT static MaybeObject* CopyElementsImpl(FixedArrayBase* from, | 792 MUST_USE_RESULT static MaybeObject* CopyElementsImpl(FixedArrayBase* from, |
| 790 uint32_t from_start, | 793 uint32_t from_start, |
| 791 FixedArrayBase* to, | 794 FixedArrayBase* to, |
| 792 ElementsKind from_kind, | 795 ElementsKind from_kind, |
| 793 uint32_t to_start, | 796 uint32_t to_start, |
| 794 int packed_size, | 797 int packed_size, |
| 795 int copy_size) { | 798 int copy_size) { |
| 796 UNREACHABLE(); | 799 UNREACHABLE(); |
| 797 return NULL; | 800 return NULL; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 814 Object); | 817 Object); |
| 815 } | 818 } |
| 816 | 819 |
| 817 virtual void CopyElements( | 820 virtual void CopyElements( |
| 818 Handle<JSObject> from_holder, | 821 Handle<JSObject> from_holder, |
| 819 uint32_t from_start, | 822 uint32_t from_start, |
| 820 ElementsKind from_kind, | 823 ElementsKind from_kind, |
| 821 Handle<FixedArrayBase> to, | 824 Handle<FixedArrayBase> to, |
| 822 uint32_t to_start, | 825 uint32_t to_start, |
| 823 int copy_size, | 826 int copy_size, |
| 824 Handle<FixedArrayBase> from) { | 827 Handle<FixedArrayBase> from) V8_FINAL V8_OVERRIDE { |
| 825 Handle<Object> result = CopyElementsHelper( | 828 Handle<Object> result = CopyElementsHelper( |
| 826 from_holder, from_start, from_kind, to, to_start, copy_size, from); | 829 from_holder, from_start, from_kind, to, to_start, copy_size, from); |
| 827 ASSERT(!result.is_null()); | 830 ASSERT(!result.is_null()); |
| 828 USE(result); | 831 USE(result); |
| 829 } | 832 } |
| 830 | 833 |
| 831 MUST_USE_RESULT virtual MaybeObject* CopyElements(JSObject* from_holder, | 834 MUST_USE_RESULT virtual MaybeObject* CopyElements( |
| 832 uint32_t from_start, | 835 JSObject* from_holder, |
| 833 ElementsKind from_kind, | 836 uint32_t from_start, |
| 834 FixedArrayBase* to, | 837 ElementsKind from_kind, |
| 835 uint32_t to_start, | 838 FixedArrayBase* to, |
| 836 int copy_size, | 839 uint32_t to_start, |
| 837 FixedArrayBase* from) { | 840 int copy_size, |
| 841 FixedArrayBase* from) V8_FINAL V8_OVERRIDE { |
| 838 int packed_size = kPackedSizeNotKnown; | 842 int packed_size = kPackedSizeNotKnown; |
| 839 if (from == NULL) { | 843 if (from == NULL) { |
| 840 from = from_holder->elements(); | 844 from = from_holder->elements(); |
| 841 } | 845 } |
| 842 | 846 |
| 843 if (from_holder) { | 847 if (from_holder) { |
| 844 bool is_packed = IsFastPackedElementsKind(from_kind) && | 848 bool is_packed = IsFastPackedElementsKind(from_kind) && |
| 845 from_holder->IsJSArray(); | 849 from_holder->IsJSArray(); |
| 846 if (is_packed) { | 850 if (is_packed) { |
| 847 packed_size = Smi::cast(JSArray::cast(from_holder)->length())->value(); | 851 packed_size = Smi::cast(JSArray::cast(from_holder)->length())->value(); |
| 848 if (copy_size >= 0 && packed_size > copy_size) { | 852 if (copy_size >= 0 && packed_size > copy_size) { |
| 849 packed_size = copy_size; | 853 packed_size = copy_size; |
| 850 } | 854 } |
| 851 } | 855 } |
| 852 } | 856 } |
| 853 return ElementsAccessorSubclass::CopyElementsImpl( | 857 return ElementsAccessorSubclass::CopyElementsImpl( |
| 854 from, from_start, to, from_kind, to_start, packed_size, copy_size); | 858 from, from_start, to, from_kind, to_start, packed_size, copy_size); |
| 855 } | 859 } |
| 856 | 860 |
| 857 MUST_USE_RESULT virtual MaybeObject* AddElementsToFixedArray( | 861 MUST_USE_RESULT virtual MaybeObject* AddElementsToFixedArray( |
| 858 Object* receiver, | 862 Object* receiver, |
| 859 JSObject* holder, | 863 JSObject* holder, |
| 860 FixedArray* to, | 864 FixedArray* to, |
| 861 FixedArrayBase* from) { | 865 FixedArrayBase* from) V8_FINAL V8_OVERRIDE { |
| 862 int len0 = to->length(); | 866 int len0 = to->length(); |
| 863 #ifdef ENABLE_SLOW_ASSERTS | 867 #ifdef ENABLE_SLOW_ASSERTS |
| 864 if (FLAG_enable_slow_asserts) { | 868 if (FLAG_enable_slow_asserts) { |
| 865 for (int i = 0; i < len0; i++) { | 869 for (int i = 0; i < len0; i++) { |
| 866 ASSERT(!to->get(i)->IsTheHole()); | 870 ASSERT(!to->get(i)->IsTheHole()); |
| 867 } | 871 } |
| 868 } | 872 } |
| 869 #endif | 873 #endif |
| 870 if (from == NULL) { | 874 if (from == NULL) { |
| 871 from = holder->elements(); | 875 from = holder->elements(); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 929 } | 933 } |
| 930 ASSERT(extra == index); | 934 ASSERT(extra == index); |
| 931 return result; | 935 return result; |
| 932 } | 936 } |
| 933 | 937 |
| 934 protected: | 938 protected: |
| 935 static uint32_t GetCapacityImpl(FixedArrayBase* backing_store) { | 939 static uint32_t GetCapacityImpl(FixedArrayBase* backing_store) { |
| 936 return backing_store->length(); | 940 return backing_store->length(); |
| 937 } | 941 } |
| 938 | 942 |
| 939 virtual uint32_t GetCapacity(FixedArrayBase* backing_store) { | 943 virtual uint32_t GetCapacity(FixedArrayBase* backing_store) |
| 944 V8_FINAL V8_OVERRIDE { |
| 940 return ElementsAccessorSubclass::GetCapacityImpl(backing_store); | 945 return ElementsAccessorSubclass::GetCapacityImpl(backing_store); |
| 941 } | 946 } |
| 942 | 947 |
| 943 static uint32_t GetKeyForIndexImpl(FixedArrayBase* backing_store, | 948 static uint32_t GetKeyForIndexImpl(FixedArrayBase* backing_store, |
| 944 uint32_t index) { | 949 uint32_t index) { |
| 945 return index; | 950 return index; |
| 946 } | 951 } |
| 947 | 952 |
| 948 virtual uint32_t GetKeyForIndex(FixedArrayBase* backing_store, | 953 virtual uint32_t GetKeyForIndex(FixedArrayBase* backing_store, |
| 949 uint32_t index) { | 954 uint32_t index) V8_FINAL V8_OVERRIDE { |
| 950 return ElementsAccessorSubclass::GetKeyForIndexImpl(backing_store, index); | 955 return ElementsAccessorSubclass::GetKeyForIndexImpl(backing_store, index); |
| 951 } | 956 } |
| 952 | 957 |
| 953 private: | 958 private: |
| 954 DISALLOW_COPY_AND_ASSIGN(ElementsAccessorBase); | 959 DISALLOW_COPY_AND_ASSIGN(ElementsAccessorBase); |
| 955 }; | 960 }; |
| 956 | 961 |
| 957 | 962 |
| 958 // Super class for all fast element arrays. | 963 // Super class for all fast element arrays. |
| 959 template<typename FastElementsAccessorSubclass, | 964 template<typename FastElementsAccessorSubclass, |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1095 if (4 * num_used > backing_store->length()) break; | 1100 if (4 * num_used > backing_store->length()) break; |
| 1096 } | 1101 } |
| 1097 if (4 * num_used <= backing_store->length()) { | 1102 if (4 * num_used <= backing_store->length()) { |
| 1098 JSObject::NormalizeElements(obj); | 1103 JSObject::NormalizeElements(obj); |
| 1099 } | 1104 } |
| 1100 } | 1105 } |
| 1101 } | 1106 } |
| 1102 return isolate->factory()->true_value(); | 1107 return isolate->factory()->true_value(); |
| 1103 } | 1108 } |
| 1104 | 1109 |
| 1105 virtual Handle<Object> Delete(Handle<JSObject> obj, | 1110 virtual Handle<Object> Delete( |
| 1106 uint32_t key, | 1111 Handle<JSObject> obj, |
| 1107 JSReceiver::DeleteMode mode) { | 1112 uint32_t key, |
| 1113 JSReceiver::DeleteMode mode) V8_FINAL V8_OVERRIDE { |
| 1108 return DeleteCommon(obj, key, mode); | 1114 return DeleteCommon(obj, key, mode); |
| 1109 } | 1115 } |
| 1110 | 1116 |
| 1111 static bool HasElementImpl( | 1117 static bool HasElementImpl( |
| 1112 Object* receiver, | 1118 Object* receiver, |
| 1113 JSObject* holder, | 1119 JSObject* holder, |
| 1114 uint32_t key, | 1120 uint32_t key, |
| 1115 FixedArrayBase* backing_store) { | 1121 FixedArrayBase* backing_store) { |
| 1116 if (key >= static_cast<uint32_t>(backing_store->length())) { | 1122 if (key >= static_cast<uint32_t>(backing_store->length())) { |
| 1117 return false; | 1123 return false; |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1429 | 1435 |
| 1430 MUST_USE_RESULT static Handle<Object> SetLengthImpl( | 1436 MUST_USE_RESULT static Handle<Object> SetLengthImpl( |
| 1431 Handle<JSObject> obj, | 1437 Handle<JSObject> obj, |
| 1432 Handle<Object> length, | 1438 Handle<Object> length, |
| 1433 Handle<FixedArrayBase> backing_store) { | 1439 Handle<FixedArrayBase> backing_store) { |
| 1434 // External arrays do not support changing their length. | 1440 // External arrays do not support changing their length. |
| 1435 UNREACHABLE(); | 1441 UNREACHABLE(); |
| 1436 return obj; | 1442 return obj; |
| 1437 } | 1443 } |
| 1438 | 1444 |
| 1439 MUST_USE_RESULT virtual Handle<Object> Delete(Handle<JSObject> obj, | 1445 MUST_USE_RESULT virtual Handle<Object> Delete( |
| 1440 uint32_t key, | 1446 Handle<JSObject> obj, |
| 1441 JSReceiver::DeleteMode mode) { | 1447 uint32_t key, |
| 1448 JSReceiver::DeleteMode mode) V8_FINAL V8_OVERRIDE { |
| 1442 // External arrays always ignore deletes. | 1449 // External arrays always ignore deletes. |
| 1443 return obj->GetIsolate()->factory()->true_value(); | 1450 return obj->GetIsolate()->factory()->true_value(); |
| 1444 } | 1451 } |
| 1445 | 1452 |
| 1446 static bool HasElementImpl(Object* receiver, | 1453 static bool HasElementImpl(Object* receiver, |
| 1447 JSObject* holder, | 1454 JSObject* holder, |
| 1448 uint32_t key, | 1455 uint32_t key, |
| 1449 FixedArrayBase* backing_store) { | 1456 FixedArrayBase* backing_store) { |
| 1450 uint32_t capacity = | 1457 uint32_t capacity = |
| 1451 AccessorClass::GetCapacityImpl(backing_store); | 1458 AccessorClass::GetCapacityImpl(backing_store); |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1614 int copy_size) { | 1621 int copy_size) { |
| 1615 UNREACHABLE(); | 1622 UNREACHABLE(); |
| 1616 return NULL; | 1623 return NULL; |
| 1617 } | 1624 } |
| 1618 | 1625 |
| 1619 | 1626 |
| 1620 protected: | 1627 protected: |
| 1621 friend class ElementsAccessorBase<DictionaryElementsAccessor, | 1628 friend class ElementsAccessorBase<DictionaryElementsAccessor, |
| 1622 ElementsKindTraits<DICTIONARY_ELEMENTS> >; | 1629 ElementsKindTraits<DICTIONARY_ELEMENTS> >; |
| 1623 | 1630 |
| 1624 MUST_USE_RESULT virtual Handle<Object> Delete(Handle<JSObject> obj, | 1631 MUST_USE_RESULT virtual Handle<Object> Delete( |
| 1625 uint32_t key, | 1632 Handle<JSObject> obj, |
| 1626 JSReceiver::DeleteMode mode) { | 1633 uint32_t key, |
| 1634 JSReceiver::DeleteMode mode) V8_FINAL V8_OVERRIDE { |
| 1627 return DeleteCommon(obj, key, mode); | 1635 return DeleteCommon(obj, key, mode); |
| 1628 } | 1636 } |
| 1629 | 1637 |
| 1630 MUST_USE_RESULT static MaybeObject* GetImpl( | 1638 MUST_USE_RESULT static MaybeObject* GetImpl( |
| 1631 Object* receiver, | 1639 Object* receiver, |
| 1632 JSObject* obj, | 1640 JSObject* obj, |
| 1633 uint32_t key, | 1641 uint32_t key, |
| 1634 FixedArrayBase* store) { | 1642 FixedArrayBase* store) { |
| 1635 SeededNumberDictionary* backing_store = SeededNumberDictionary::cast(store); | 1643 SeededNumberDictionary* backing_store = SeededNumberDictionary::cast(store); |
| 1636 int entry = backing_store->FindEntry(key); | 1644 int entry = backing_store->FindEntry(key); |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1806 MUST_USE_RESULT static Handle<Object> SetLengthImpl( | 1814 MUST_USE_RESULT static Handle<Object> SetLengthImpl( |
| 1807 Handle<JSObject> obj, | 1815 Handle<JSObject> obj, |
| 1808 Handle<Object> length, | 1816 Handle<Object> length, |
| 1809 Handle<FixedArrayBase> parameter_map) { | 1817 Handle<FixedArrayBase> parameter_map) { |
| 1810 // TODO(mstarzinger): This was never implemented but will be used once we | 1818 // TODO(mstarzinger): This was never implemented but will be used once we |
| 1811 // correctly implement [[DefineOwnProperty]] on arrays. | 1819 // correctly implement [[DefineOwnProperty]] on arrays. |
| 1812 UNIMPLEMENTED(); | 1820 UNIMPLEMENTED(); |
| 1813 return obj; | 1821 return obj; |
| 1814 } | 1822 } |
| 1815 | 1823 |
| 1816 MUST_USE_RESULT virtual Handle<Object> Delete(Handle<JSObject> obj, | 1824 MUST_USE_RESULT virtual Handle<Object> Delete( |
| 1817 uint32_t key, | 1825 Handle<JSObject> obj, |
| 1818 JSReceiver::DeleteMode mode) { | 1826 uint32_t key, |
| 1827 JSReceiver::DeleteMode mode) V8_FINAL V8_OVERRIDE { |
| 1819 Isolate* isolate = obj->GetIsolate(); | 1828 Isolate* isolate = obj->GetIsolate(); |
| 1820 Handle<FixedArray> parameter_map = | 1829 Handle<FixedArray> parameter_map = |
| 1821 handle(FixedArray::cast(obj->elements()), isolate); | 1830 handle(FixedArray::cast(obj->elements()), isolate); |
| 1822 Handle<Object> probe = GetParameterMapArg(obj, parameter_map, key); | 1831 Handle<Object> probe = GetParameterMapArg(obj, parameter_map, key); |
| 1823 if (!probe->IsTheHole()) { | 1832 if (!probe->IsTheHole()) { |
| 1824 // TODO(kmillikin): We could check if this was the last aliased | 1833 // TODO(kmillikin): We could check if this was the last aliased |
| 1825 // parameter, and revert to normal elements in that case. That | 1834 // parameter, and revert to normal elements in that case. That |
| 1826 // would enable GC of the context. | 1835 // would enable GC of the context. |
| 1827 parameter_map->set_the_hole(key + 2); | 1836 parameter_map->set_the_hole(key + 2); |
| 1828 } else { | 1837 } else { |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2086 UNREACHABLE(); | 2095 UNREACHABLE(); |
| 2087 break; | 2096 break; |
| 2088 } | 2097 } |
| 2089 | 2098 |
| 2090 array->set_elements(*elms); | 2099 array->set_elements(*elms); |
| 2091 array->set_length(Smi::FromInt(number_of_elements)); | 2100 array->set_length(Smi::FromInt(number_of_elements)); |
| 2092 return array; | 2101 return array; |
| 2093 } | 2102 } |
| 2094 | 2103 |
| 2095 } } // namespace v8::internal | 2104 } } // namespace v8::internal |
| OLD | NEW |