OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/arguments.h" | 7 #include "src/arguments.h" |
8 #include "src/conversions.h" | 8 #include "src/conversions.h" |
9 #include "src/elements.h" | 9 #include "src/elements.h" |
10 #include "src/objects.h" | 10 #include "src/objects.h" |
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
553 template <typename ElementsAccessorSubclass, | 553 template <typename ElementsAccessorSubclass, |
554 typename ElementsTraitsParam> | 554 typename ElementsTraitsParam> |
555 class ElementsAccessorBase : public ElementsAccessor { | 555 class ElementsAccessorBase : public ElementsAccessor { |
556 protected: | 556 protected: |
557 explicit ElementsAccessorBase(const char* name) | 557 explicit ElementsAccessorBase(const char* name) |
558 : ElementsAccessor(name) { } | 558 : ElementsAccessor(name) { } |
559 | 559 |
560 typedef ElementsTraitsParam ElementsTraits; | 560 typedef ElementsTraitsParam ElementsTraits; |
561 typedef typename ElementsTraitsParam::BackingStore BackingStore; | 561 typedef typename ElementsTraitsParam::BackingStore BackingStore; |
562 | 562 |
563 virtual ElementsKind kind() const FINAL OVERRIDE { | 563 ElementsKind kind() const FINAL { return ElementsTraits::Kind; } |
564 return ElementsTraits::Kind; | |
565 } | |
566 | 564 |
567 static void ValidateContents(Handle<JSObject> holder, int length) { | 565 static void ValidateContents(Handle<JSObject> holder, int length) { |
568 } | 566 } |
569 | 567 |
570 static void ValidateImpl(Handle<JSObject> holder) { | 568 static void ValidateImpl(Handle<JSObject> holder) { |
571 Handle<FixedArrayBase> fixed_array_base(holder->elements()); | 569 Handle<FixedArrayBase> fixed_array_base(holder->elements()); |
572 if (!fixed_array_base->IsHeapObject()) return; | 570 if (!fixed_array_base->IsHeapObject()) return; |
573 // Arrays that have been shifted in place can't be verified. | 571 // Arrays that have been shifted in place can't be verified. |
574 if (fixed_array_base->IsFiller()) return; | 572 if (fixed_array_base->IsFiller()) return; |
575 int length = 0; | 573 int length = 0; |
576 if (holder->IsJSArray()) { | 574 if (holder->IsJSArray()) { |
577 Object* length_obj = Handle<JSArray>::cast(holder)->length(); | 575 Object* length_obj = Handle<JSArray>::cast(holder)->length(); |
578 if (length_obj->IsSmi()) { | 576 if (length_obj->IsSmi()) { |
579 length = Smi::cast(length_obj)->value(); | 577 length = Smi::cast(length_obj)->value(); |
580 } | 578 } |
581 } else { | 579 } else { |
582 length = fixed_array_base->length(); | 580 length = fixed_array_base->length(); |
583 } | 581 } |
584 ElementsAccessorSubclass::ValidateContents(holder, length); | 582 ElementsAccessorSubclass::ValidateContents(holder, length); |
585 } | 583 } |
586 | 584 |
587 virtual void Validate(Handle<JSObject> holder) FINAL OVERRIDE { | 585 void Validate(Handle<JSObject> holder) FINAL { |
588 DisallowHeapAllocation no_gc; | 586 DisallowHeapAllocation no_gc; |
589 ElementsAccessorSubclass::ValidateImpl(holder); | 587 ElementsAccessorSubclass::ValidateImpl(holder); |
590 } | 588 } |
591 | 589 |
592 static bool HasElementImpl(Handle<Object> receiver, | 590 static bool HasElementImpl(Handle<Object> receiver, |
593 Handle<JSObject> holder, | 591 Handle<JSObject> holder, |
594 uint32_t key, | 592 uint32_t key, |
595 Handle<FixedArrayBase> backing_store) { | 593 Handle<FixedArrayBase> backing_store) { |
596 return ElementsAccessorSubclass::GetAttributesImpl( | 594 return ElementsAccessorSubclass::GetAttributesImpl( |
597 receiver, holder, key, backing_store) != ABSENT; | 595 receiver, holder, key, backing_store) != ABSENT; |
598 } | 596 } |
599 | 597 |
600 virtual bool HasElement( | 598 virtual bool HasElement(Handle<Object> receiver, Handle<JSObject> holder, |
601 Handle<Object> receiver, | 599 uint32_t key, |
602 Handle<JSObject> holder, | 600 Handle<FixedArrayBase> backing_store) FINAL { |
603 uint32_t key, | |
604 Handle<FixedArrayBase> backing_store) FINAL OVERRIDE { | |
605 return ElementsAccessorSubclass::HasElementImpl( | 601 return ElementsAccessorSubclass::HasElementImpl( |
606 receiver, holder, key, backing_store); | 602 receiver, holder, key, backing_store); |
607 } | 603 } |
608 | 604 |
609 MUST_USE_RESULT virtual MaybeHandle<Object> Get( | 605 MUST_USE_RESULT virtual MaybeHandle<Object> Get( |
610 Handle<Object> receiver, | 606 Handle<Object> receiver, Handle<JSObject> holder, uint32_t key, |
611 Handle<JSObject> holder, | 607 Handle<FixedArrayBase> backing_store) FINAL { |
612 uint32_t key, | |
613 Handle<FixedArrayBase> backing_store) FINAL OVERRIDE { | |
614 if (!IsExternalArrayElementsKind(ElementsTraits::Kind) && | 608 if (!IsExternalArrayElementsKind(ElementsTraits::Kind) && |
615 FLAG_trace_js_array_abuse) { | 609 FLAG_trace_js_array_abuse) { |
616 CheckArrayAbuse(holder, "elements read", key); | 610 CheckArrayAbuse(holder, "elements read", key); |
617 } | 611 } |
618 | 612 |
619 if (IsExternalArrayElementsKind(ElementsTraits::Kind) && | 613 if (IsExternalArrayElementsKind(ElementsTraits::Kind) && |
620 FLAG_trace_external_array_abuse) { | 614 FLAG_trace_external_array_abuse) { |
621 CheckArrayAbuse(holder, "external elements read", key); | 615 CheckArrayAbuse(holder, "external elements read", key); |
622 } | 616 } |
623 | 617 |
624 return ElementsAccessorSubclass::GetImpl( | 618 return ElementsAccessorSubclass::GetImpl( |
625 receiver, holder, key, backing_store); | 619 receiver, holder, key, backing_store); |
626 } | 620 } |
627 | 621 |
628 MUST_USE_RESULT static MaybeHandle<Object> GetImpl( | 622 MUST_USE_RESULT static MaybeHandle<Object> GetImpl( |
629 Handle<Object> receiver, | 623 Handle<Object> receiver, |
630 Handle<JSObject> obj, | 624 Handle<JSObject> obj, |
631 uint32_t key, | 625 uint32_t key, |
632 Handle<FixedArrayBase> backing_store) { | 626 Handle<FixedArrayBase> backing_store) { |
633 if (key < ElementsAccessorSubclass::GetCapacityImpl(backing_store)) { | 627 if (key < ElementsAccessorSubclass::GetCapacityImpl(backing_store)) { |
634 return BackingStore::get(Handle<BackingStore>::cast(backing_store), key); | 628 return BackingStore::get(Handle<BackingStore>::cast(backing_store), key); |
635 } else { | 629 } else { |
636 return backing_store->GetIsolate()->factory()->the_hole_value(); | 630 return backing_store->GetIsolate()->factory()->the_hole_value(); |
637 } | 631 } |
638 } | 632 } |
639 | 633 |
640 MUST_USE_RESULT virtual PropertyAttributes GetAttributes( | 634 MUST_USE_RESULT virtual PropertyAttributes GetAttributes( |
641 Handle<Object> receiver, | 635 Handle<Object> receiver, Handle<JSObject> holder, uint32_t key, |
642 Handle<JSObject> holder, | 636 Handle<FixedArrayBase> backing_store) FINAL { |
643 uint32_t key, | |
644 Handle<FixedArrayBase> backing_store) FINAL OVERRIDE { | |
645 return ElementsAccessorSubclass::GetAttributesImpl( | 637 return ElementsAccessorSubclass::GetAttributesImpl( |
646 receiver, holder, key, backing_store); | 638 receiver, holder, key, backing_store); |
647 } | 639 } |
648 | 640 |
649 MUST_USE_RESULT static PropertyAttributes GetAttributesImpl( | 641 MUST_USE_RESULT static PropertyAttributes GetAttributesImpl( |
650 Handle<Object> receiver, | 642 Handle<Object> receiver, |
651 Handle<JSObject> obj, | 643 Handle<JSObject> obj, |
652 uint32_t key, | 644 uint32_t key, |
653 Handle<FixedArrayBase> backing_store) { | 645 Handle<FixedArrayBase> backing_store) { |
654 if (key >= ElementsAccessorSubclass::GetCapacityImpl(backing_store)) { | 646 if (key >= ElementsAccessorSubclass::GetCapacityImpl(backing_store)) { |
655 return ABSENT; | 647 return ABSENT; |
656 } | 648 } |
657 return | 649 return |
658 Handle<BackingStore>::cast(backing_store)->is_the_hole(key) | 650 Handle<BackingStore>::cast(backing_store)->is_the_hole(key) |
659 ? ABSENT : NONE; | 651 ? ABSENT : NONE; |
660 } | 652 } |
661 | 653 |
662 MUST_USE_RESULT virtual MaybeHandle<AccessorPair> GetAccessorPair( | 654 MUST_USE_RESULT virtual MaybeHandle<AccessorPair> GetAccessorPair( |
663 Handle<Object> receiver, | 655 Handle<Object> receiver, Handle<JSObject> holder, uint32_t key, |
664 Handle<JSObject> holder, | 656 Handle<FixedArrayBase> backing_store) FINAL { |
665 uint32_t key, | |
666 Handle<FixedArrayBase> backing_store) FINAL OVERRIDE { | |
667 return ElementsAccessorSubclass::GetAccessorPairImpl( | 657 return ElementsAccessorSubclass::GetAccessorPairImpl( |
668 receiver, holder, key, backing_store); | 658 receiver, holder, key, backing_store); |
669 } | 659 } |
670 | 660 |
671 MUST_USE_RESULT static MaybeHandle<AccessorPair> GetAccessorPairImpl( | 661 MUST_USE_RESULT static MaybeHandle<AccessorPair> GetAccessorPairImpl( |
672 Handle<Object> receiver, | 662 Handle<Object> receiver, |
673 Handle<JSObject> obj, | 663 Handle<JSObject> obj, |
674 uint32_t key, | 664 uint32_t key, |
675 Handle<FixedArrayBase> backing_store) { | 665 Handle<FixedArrayBase> backing_store) { |
676 return MaybeHandle<AccessorPair>(); | 666 return MaybeHandle<AccessorPair>(); |
677 } | 667 } |
678 | 668 |
679 MUST_USE_RESULT virtual MaybeHandle<Object> SetLength( | 669 MUST_USE_RESULT virtual MaybeHandle<Object> SetLength( |
680 Handle<JSArray> array, | 670 Handle<JSArray> array, Handle<Object> length) FINAL { |
681 Handle<Object> length) FINAL OVERRIDE { | |
682 return ElementsAccessorSubclass::SetLengthImpl( | 671 return ElementsAccessorSubclass::SetLengthImpl( |
683 array, length, handle(array->elements())); | 672 array, length, handle(array->elements())); |
684 } | 673 } |
685 | 674 |
686 MUST_USE_RESULT static MaybeHandle<Object> SetLengthImpl( | 675 MUST_USE_RESULT static MaybeHandle<Object> SetLengthImpl( |
687 Handle<JSObject> obj, | 676 Handle<JSObject> obj, |
688 Handle<Object> length, | 677 Handle<Object> length, |
689 Handle<FixedArrayBase> backing_store); | 678 Handle<FixedArrayBase> backing_store); |
690 | 679 |
691 virtual void SetCapacityAndLength( | 680 virtual void SetCapacityAndLength(Handle<JSArray> array, int capacity, |
692 Handle<JSArray> array, | 681 int length) FINAL { |
693 int capacity, | |
694 int length) FINAL OVERRIDE { | |
695 ElementsAccessorSubclass:: | 682 ElementsAccessorSubclass:: |
696 SetFastElementsCapacityAndLength(array, capacity, length); | 683 SetFastElementsCapacityAndLength(array, capacity, length); |
697 } | 684 } |
698 | 685 |
699 static void SetFastElementsCapacityAndLength( | 686 static void SetFastElementsCapacityAndLength( |
700 Handle<JSObject> obj, | 687 Handle<JSObject> obj, |
701 int capacity, | 688 int capacity, |
702 int length) { | 689 int length) { |
703 UNIMPLEMENTED(); | 690 UNIMPLEMENTED(); |
704 } | 691 } |
705 | 692 |
706 MUST_USE_RESULT virtual MaybeHandle<Object> Delete( | 693 MUST_USE_RESULT virtual MaybeHandle<Object> Delete( |
707 Handle<JSObject> obj, | 694 Handle<JSObject> obj, |
708 uint32_t key, | 695 uint32_t key, |
709 JSReceiver::DeleteMode mode) OVERRIDE = 0; | 696 JSReceiver::DeleteMode mode) OVERRIDE = 0; |
710 | 697 |
711 static void CopyElementsImpl(FixedArrayBase* from, uint32_t from_start, | 698 static void CopyElementsImpl(FixedArrayBase* from, uint32_t from_start, |
712 FixedArrayBase* to, ElementsKind from_kind, | 699 FixedArrayBase* to, ElementsKind from_kind, |
713 uint32_t to_start, int packed_size, | 700 uint32_t to_start, int packed_size, |
714 int copy_size) { | 701 int copy_size) { |
715 UNREACHABLE(); | 702 UNREACHABLE(); |
716 } | 703 } |
717 | 704 |
718 virtual void CopyElements( | 705 virtual void CopyElements(Handle<FixedArrayBase> from, uint32_t from_start, |
719 Handle<FixedArrayBase> from, | 706 ElementsKind from_kind, Handle<FixedArrayBase> to, |
720 uint32_t from_start, | 707 uint32_t to_start, int copy_size) FINAL { |
721 ElementsKind from_kind, | |
722 Handle<FixedArrayBase> to, | |
723 uint32_t to_start, | |
724 int copy_size) FINAL OVERRIDE { | |
725 DCHECK(!from.is_null()); | 708 DCHECK(!from.is_null()); |
726 // NOTE: the ElementsAccessorSubclass::CopyElementsImpl() methods | 709 // NOTE: the ElementsAccessorSubclass::CopyElementsImpl() methods |
727 // violate the handlified function signature convention: | 710 // violate the handlified function signature convention: |
728 // raw pointer parameters in the function that allocates. This is done | 711 // raw pointer parameters in the function that allocates. This is done |
729 // intentionally to avoid ArrayConcat() builtin performance degradation. | 712 // intentionally to avoid ArrayConcat() builtin performance degradation. |
730 // See the comment in another ElementsAccessorBase::CopyElements() for | 713 // See the comment in another ElementsAccessorBase::CopyElements() for |
731 // details. | 714 // details. |
732 ElementsAccessorSubclass::CopyElementsImpl(*from, from_start, *to, | 715 ElementsAccessorSubclass::CopyElementsImpl(*from, from_start, *to, |
733 from_kind, to_start, | 716 from_kind, to_start, |
734 kPackedSizeNotKnown, copy_size); | 717 kPackedSizeNotKnown, copy_size); |
735 } | 718 } |
736 | 719 |
737 virtual void CopyElements( | 720 virtual void CopyElements(JSObject* from_holder, uint32_t from_start, |
738 JSObject* from_holder, | 721 ElementsKind from_kind, Handle<FixedArrayBase> to, |
739 uint32_t from_start, | 722 uint32_t to_start, int copy_size) FINAL { |
740 ElementsKind from_kind, | |
741 Handle<FixedArrayBase> to, | |
742 uint32_t to_start, | |
743 int copy_size) FINAL OVERRIDE { | |
744 int packed_size = kPackedSizeNotKnown; | 723 int packed_size = kPackedSizeNotKnown; |
745 bool is_packed = IsFastPackedElementsKind(from_kind) && | 724 bool is_packed = IsFastPackedElementsKind(from_kind) && |
746 from_holder->IsJSArray(); | 725 from_holder->IsJSArray(); |
747 if (is_packed) { | 726 if (is_packed) { |
748 packed_size = | 727 packed_size = |
749 Smi::cast(JSArray::cast(from_holder)->length())->value(); | 728 Smi::cast(JSArray::cast(from_holder)->length())->value(); |
750 if (copy_size >= 0 && packed_size > copy_size) { | 729 if (copy_size >= 0 && packed_size > copy_size) { |
751 packed_size = copy_size; | 730 packed_size = copy_size; |
752 } | 731 } |
753 } | 732 } |
754 FixedArrayBase* from = from_holder->elements(); | 733 FixedArrayBase* from = from_holder->elements(); |
755 // NOTE: the ElementsAccessorSubclass::CopyElementsImpl() methods | 734 // NOTE: the ElementsAccessorSubclass::CopyElementsImpl() methods |
756 // violate the handlified function signature convention: | 735 // violate the handlified function signature convention: |
757 // raw pointer parameters in the function that allocates. This is done | 736 // raw pointer parameters in the function that allocates. This is done |
758 // intentionally to avoid ArrayConcat() builtin performance degradation. | 737 // intentionally to avoid ArrayConcat() builtin performance degradation. |
759 // | 738 // |
760 // Details: The idea is that allocations actually happen only in case of | 739 // Details: The idea is that allocations actually happen only in case of |
761 // copying from object with fast double elements to object with object | 740 // copying from object with fast double elements to object with object |
762 // elements. In all the other cases there are no allocations performed and | 741 // elements. In all the other cases there are no allocations performed and |
763 // handle creation causes noticeable performance degradation of the builtin. | 742 // handle creation causes noticeable performance degradation of the builtin. |
764 ElementsAccessorSubclass::CopyElementsImpl( | 743 ElementsAccessorSubclass::CopyElementsImpl( |
765 from, from_start, *to, from_kind, to_start, packed_size, copy_size); | 744 from, from_start, *to, from_kind, to_start, packed_size, copy_size); |
766 } | 745 } |
767 | 746 |
768 virtual MaybeHandle<FixedArray> AddElementsToFixedArray( | 747 virtual MaybeHandle<FixedArray> AddElementsToFixedArray( |
769 Handle<Object> receiver, Handle<JSObject> holder, Handle<FixedArray> to, | 748 Handle<Object> receiver, Handle<JSObject> holder, Handle<FixedArray> to, |
770 Handle<FixedArrayBase> from, | 749 Handle<FixedArrayBase> from, FixedArray::KeyFilter filter) FINAL { |
771 FixedArray::KeyFilter filter) FINAL OVERRIDE { | |
772 int len0 = to->length(); | 750 int len0 = to->length(); |
773 #ifdef ENABLE_SLOW_DCHECKS | 751 #ifdef ENABLE_SLOW_DCHECKS |
774 if (FLAG_enable_slow_asserts) { | 752 if (FLAG_enable_slow_asserts) { |
775 for (int i = 0; i < len0; i++) { | 753 for (int i = 0; i < len0; i++) { |
776 DCHECK(!to->get(i)->IsTheHole()); | 754 DCHECK(!to->get(i)->IsTheHole()); |
777 } | 755 } |
778 } | 756 } |
779 #endif | 757 #endif |
780 | 758 |
781 // Optimize if 'other' is empty. | 759 // Optimize if 'other' is empty. |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
845 } | 823 } |
846 DCHECK(extra == index); | 824 DCHECK(extra == index); |
847 return result; | 825 return result; |
848 } | 826 } |
849 | 827 |
850 protected: | 828 protected: |
851 static uint32_t GetCapacityImpl(Handle<FixedArrayBase> backing_store) { | 829 static uint32_t GetCapacityImpl(Handle<FixedArrayBase> backing_store) { |
852 return backing_store->length(); | 830 return backing_store->length(); |
853 } | 831 } |
854 | 832 |
855 virtual uint32_t GetCapacity(Handle<FixedArrayBase> backing_store) | 833 uint32_t GetCapacity(Handle<FixedArrayBase> backing_store) FINAL { |
856 FINAL OVERRIDE { | |
857 return ElementsAccessorSubclass::GetCapacityImpl(backing_store); | 834 return ElementsAccessorSubclass::GetCapacityImpl(backing_store); |
858 } | 835 } |
859 | 836 |
860 static uint32_t GetKeyForIndexImpl(Handle<FixedArrayBase> backing_store, | 837 static uint32_t GetKeyForIndexImpl(Handle<FixedArrayBase> backing_store, |
861 uint32_t index) { | 838 uint32_t index) { |
862 return index; | 839 return index; |
863 } | 840 } |
864 | 841 |
865 virtual uint32_t GetKeyForIndex(Handle<FixedArrayBase> backing_store, | 842 virtual uint32_t GetKeyForIndex(Handle<FixedArrayBase> backing_store, |
866 uint32_t index) FINAL OVERRIDE { | 843 uint32_t index) FINAL { |
867 return ElementsAccessorSubclass::GetKeyForIndexImpl(backing_store, index); | 844 return ElementsAccessorSubclass::GetKeyForIndexImpl(backing_store, index); |
868 } | 845 } |
869 | 846 |
870 private: | 847 private: |
871 DISALLOW_COPY_AND_ASSIGN(ElementsAccessorBase); | 848 DISALLOW_COPY_AND_ASSIGN(ElementsAccessorBase); |
872 }; | 849 }; |
873 | 850 |
874 | 851 |
875 // Super class for all fast element arrays. | 852 // Super class for all fast element arrays. |
876 template<typename FastElementsAccessorSubclass, | 853 template<typename FastElementsAccessorSubclass, |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
990 if (4 * num_used > backing_store->length()) break; | 967 if (4 * num_used > backing_store->length()) break; |
991 } | 968 } |
992 if (4 * num_used <= backing_store->length()) { | 969 if (4 * num_used <= backing_store->length()) { |
993 JSObject::NormalizeElements(obj); | 970 JSObject::NormalizeElements(obj); |
994 } | 971 } |
995 } | 972 } |
996 } | 973 } |
997 return isolate->factory()->true_value(); | 974 return isolate->factory()->true_value(); |
998 } | 975 } |
999 | 976 |
1000 virtual MaybeHandle<Object> Delete( | 977 virtual MaybeHandle<Object> Delete(Handle<JSObject> obj, uint32_t key, |
1001 Handle<JSObject> obj, | 978 JSReceiver::DeleteMode mode) FINAL { |
1002 uint32_t key, | |
1003 JSReceiver::DeleteMode mode) FINAL OVERRIDE { | |
1004 return DeleteCommon(obj, key, mode); | 979 return DeleteCommon(obj, key, mode); |
1005 } | 980 } |
1006 | 981 |
1007 static bool HasElementImpl( | 982 static bool HasElementImpl( |
1008 Handle<Object> receiver, | 983 Handle<Object> receiver, |
1009 Handle<JSObject> holder, | 984 Handle<JSObject> holder, |
1010 uint32_t key, | 985 uint32_t key, |
1011 Handle<FixedArrayBase> backing_store) { | 986 Handle<FixedArrayBase> backing_store) { |
1012 if (key >= static_cast<uint32_t>(backing_store->length())) { | 987 if (key >= static_cast<uint32_t>(backing_store->length())) { |
1013 return false; | 988 return false; |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1316 MUST_USE_RESULT static MaybeHandle<Object> SetLengthImpl( | 1291 MUST_USE_RESULT static MaybeHandle<Object> SetLengthImpl( |
1317 Handle<JSObject> obj, | 1292 Handle<JSObject> obj, |
1318 Handle<Object> length, | 1293 Handle<Object> length, |
1319 Handle<FixedArrayBase> backing_store) { | 1294 Handle<FixedArrayBase> backing_store) { |
1320 // External arrays do not support changing their length. | 1295 // External arrays do not support changing their length. |
1321 UNREACHABLE(); | 1296 UNREACHABLE(); |
1322 return obj; | 1297 return obj; |
1323 } | 1298 } |
1324 | 1299 |
1325 MUST_USE_RESULT virtual MaybeHandle<Object> Delete( | 1300 MUST_USE_RESULT virtual MaybeHandle<Object> Delete( |
1326 Handle<JSObject> obj, | 1301 Handle<JSObject> obj, uint32_t key, JSReceiver::DeleteMode mode) FINAL { |
1327 uint32_t key, | |
1328 JSReceiver::DeleteMode mode) FINAL OVERRIDE { | |
1329 // External arrays always ignore deletes. | 1302 // External arrays always ignore deletes. |
1330 return obj->GetIsolate()->factory()->true_value(); | 1303 return obj->GetIsolate()->factory()->true_value(); |
1331 } | 1304 } |
1332 | 1305 |
1333 static bool HasElementImpl(Handle<Object> receiver, | 1306 static bool HasElementImpl(Handle<Object> receiver, |
1334 Handle<JSObject> holder, | 1307 Handle<JSObject> holder, |
1335 uint32_t key, | 1308 uint32_t key, |
1336 Handle<FixedArrayBase> backing_store) { | 1309 Handle<FixedArrayBase> backing_store) { |
1337 uint32_t capacity = | 1310 uint32_t capacity = |
1338 AccessorClass::GetCapacityImpl(backing_store); | 1311 AccessorClass::GetCapacityImpl(backing_store); |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1470 int copy_size) { | 1443 int copy_size) { |
1471 UNREACHABLE(); | 1444 UNREACHABLE(); |
1472 } | 1445 } |
1473 | 1446 |
1474 | 1447 |
1475 protected: | 1448 protected: |
1476 friend class ElementsAccessorBase<DictionaryElementsAccessor, | 1449 friend class ElementsAccessorBase<DictionaryElementsAccessor, |
1477 ElementsKindTraits<DICTIONARY_ELEMENTS> >; | 1450 ElementsKindTraits<DICTIONARY_ELEMENTS> >; |
1478 | 1451 |
1479 MUST_USE_RESULT virtual MaybeHandle<Object> Delete( | 1452 MUST_USE_RESULT virtual MaybeHandle<Object> Delete( |
1480 Handle<JSObject> obj, | 1453 Handle<JSObject> obj, uint32_t key, JSReceiver::DeleteMode mode) FINAL { |
1481 uint32_t key, | |
1482 JSReceiver::DeleteMode mode) FINAL OVERRIDE { | |
1483 return DeleteCommon(obj, key, mode); | 1454 return DeleteCommon(obj, key, mode); |
1484 } | 1455 } |
1485 | 1456 |
1486 MUST_USE_RESULT static MaybeHandle<Object> GetImpl( | 1457 MUST_USE_RESULT static MaybeHandle<Object> GetImpl( |
1487 Handle<Object> receiver, | 1458 Handle<Object> receiver, |
1488 Handle<JSObject> obj, | 1459 Handle<JSObject> obj, |
1489 uint32_t key, | 1460 uint32_t key, |
1490 Handle<FixedArrayBase> store) { | 1461 Handle<FixedArrayBase> store) { |
1491 Handle<SeededNumberDictionary> backing_store = | 1462 Handle<SeededNumberDictionary> backing_store = |
1492 Handle<SeededNumberDictionary>::cast(store); | 1463 Handle<SeededNumberDictionary>::cast(store); |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1644 Handle<JSObject> obj, | 1615 Handle<JSObject> obj, |
1645 Handle<Object> length, | 1616 Handle<Object> length, |
1646 Handle<FixedArrayBase> parameter_map) { | 1617 Handle<FixedArrayBase> parameter_map) { |
1647 // TODO(mstarzinger): This was never implemented but will be used once we | 1618 // TODO(mstarzinger): This was never implemented but will be used once we |
1648 // correctly implement [[DefineOwnProperty]] on arrays. | 1619 // correctly implement [[DefineOwnProperty]] on arrays. |
1649 UNIMPLEMENTED(); | 1620 UNIMPLEMENTED(); |
1650 return obj; | 1621 return obj; |
1651 } | 1622 } |
1652 | 1623 |
1653 MUST_USE_RESULT virtual MaybeHandle<Object> Delete( | 1624 MUST_USE_RESULT virtual MaybeHandle<Object> Delete( |
1654 Handle<JSObject> obj, | 1625 Handle<JSObject> obj, uint32_t key, JSReceiver::DeleteMode mode) FINAL { |
1655 uint32_t key, | |
1656 JSReceiver::DeleteMode mode) FINAL OVERRIDE { | |
1657 Isolate* isolate = obj->GetIsolate(); | 1626 Isolate* isolate = obj->GetIsolate(); |
1658 Handle<FixedArray> parameter_map(FixedArray::cast(obj->elements())); | 1627 Handle<FixedArray> parameter_map(FixedArray::cast(obj->elements())); |
1659 Handle<Object> probe = GetParameterMapArg(obj, parameter_map, key); | 1628 Handle<Object> probe = GetParameterMapArg(obj, parameter_map, key); |
1660 if (!probe->IsTheHole()) { | 1629 if (!probe->IsTheHole()) { |
1661 // TODO(kmillikin): We could check if this was the last aliased | 1630 // TODO(kmillikin): We could check if this was the last aliased |
1662 // parameter, and revert to normal elements in that case. That | 1631 // parameter, and revert to normal elements in that case. That |
1663 // would enable GC of the context. | 1632 // would enable GC of the context. |
1664 parameter_map->set_the_hole(key + 2); | 1633 parameter_map->set_the_hole(key + 2); |
1665 } else { | 1634 } else { |
1666 Handle<FixedArray> arguments(FixedArray::cast(parameter_map->get(1))); | 1635 Handle<FixedArray> arguments(FixedArray::cast(parameter_map->get(1))); |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1916 UNREACHABLE(); | 1885 UNREACHABLE(); |
1917 break; | 1886 break; |
1918 } | 1887 } |
1919 | 1888 |
1920 array->set_elements(*elms); | 1889 array->set_elements(*elms); |
1921 array->set_length(Smi::FromInt(number_of_elements)); | 1890 array->set_length(Smi::FromInt(number_of_elements)); |
1922 return array; | 1891 return array; |
1923 } | 1892 } |
1924 | 1893 |
1925 } } // namespace v8::internal | 1894 } } // namespace v8::internal |
OLD | NEW |