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/elements.h" | 5 #include "src/elements.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/factory.h" | 9 #include "src/factory.h" |
10 #include "src/isolate-inl.h" | 10 #include "src/isolate-inl.h" |
(...skipping 740 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
751 array->initialize_elements(); | 751 array->initialize_elements(); |
752 } else if (length <= capacity) { | 752 } else if (length <= capacity) { |
753 if (IsFastSmiOrObjectElementsKind(kind())) { | 753 if (IsFastSmiOrObjectElementsKind(kind())) { |
754 JSObject::EnsureWritableFastElements(array); | 754 JSObject::EnsureWritableFastElements(array); |
755 if (array->elements() != *backing_store) { | 755 if (array->elements() != *backing_store) { |
756 backing_store = handle(array->elements(), isolate); | 756 backing_store = handle(array->elements(), isolate); |
757 } | 757 } |
758 } | 758 } |
759 if (2 * length <= capacity) { | 759 if (2 * length <= capacity) { |
760 // If more than half the elements won't be used, trim the array. | 760 // If more than half the elements won't be used, trim the array. |
761 isolate->heap()->RightTrimFixedArray<Heap::CONCURRENT_TO_SWEEPER>( | 761 isolate->heap()->RightTrimFixedArray(*backing_store, capacity - length); |
762 *backing_store, capacity - length); | |
763 } else { | 762 } else { |
764 // Otherwise, fill the unused tail with holes. | 763 // Otherwise, fill the unused tail with holes. |
765 for (uint32_t i = length; i < old_length; i++) { | 764 for (uint32_t i = length; i < old_length; i++) { |
766 BackingStore::cast(*backing_store)->set_the_hole(i); | 765 BackingStore::cast(*backing_store)->set_the_hole(i); |
767 } | 766 } |
768 } | 767 } |
769 } else { | 768 } else { |
770 // Check whether the backing store should be expanded. | 769 // Check whether the backing store should be expanded. |
771 capacity = Max(length, JSObject::NewElementsCapacity(capacity)); | 770 capacity = Max(length, JSObject::NewElementsCapacity(capacity)); |
772 Subclass::GrowCapacityAndConvertImpl(array, capacity); | 771 Subclass::GrowCapacityAndConvertImpl(array, capacity); |
(...skipping 1019 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1792 // Dynamically ask for the elements kind here since we manually redirect | 1791 // Dynamically ask for the elements kind here since we manually redirect |
1793 // the operations for argument backing stores. | 1792 // the operations for argument backing stores. |
1794 if (obj->GetElementsKind() == FAST_SLOPPY_ARGUMENTS_ELEMENTS) { | 1793 if (obj->GetElementsKind() == FAST_SLOPPY_ARGUMENTS_ELEMENTS) { |
1795 FixedArray::cast(obj->elements())->set(1, empty); | 1794 FixedArray::cast(obj->elements())->set(1, empty); |
1796 } else { | 1795 } else { |
1797 obj->set_elements(empty); | 1796 obj->set_elements(empty); |
1798 } | 1797 } |
1799 return; | 1798 return; |
1800 } | 1799 } |
1801 | 1800 |
1802 isolate->heap()->RightTrimFixedArray<Heap::CONCURRENT_TO_SWEEPER>( | 1801 isolate->heap()->RightTrimFixedArray(*backing_store, length - entry); |
1803 *backing_store, length - entry); | |
1804 } | 1802 } |
1805 | 1803 |
1806 static void DeleteCommon(Handle<JSObject> obj, uint32_t entry, | 1804 static void DeleteCommon(Handle<JSObject> obj, uint32_t entry, |
1807 Handle<FixedArrayBase> store) { | 1805 Handle<FixedArrayBase> store) { |
1808 DCHECK(obj->HasFastSmiOrObjectElements() || obj->HasFastDoubleElements() || | 1806 DCHECK(obj->HasFastSmiOrObjectElements() || obj->HasFastDoubleElements() || |
1809 obj->HasFastArgumentsElements() || | 1807 obj->HasFastArgumentsElements() || |
1810 obj->HasFastStringWrapperElements()); | 1808 obj->HasFastStringWrapperElements()); |
1811 Handle<BackingStore> backing_store = Handle<BackingStore>::cast(store); | 1809 Handle<BackingStore> backing_store = Handle<BackingStore>::cast(store); |
1812 if (!obj->IsJSArray() && | 1810 if (!obj->IsJSArray() && |
1813 entry == static_cast<uint32_t>(store->length()) - 1) { | 1811 entry == static_cast<uint32_t>(store->length()) - 1) { |
(...skipping 2012 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3826 insertion_index += len; | 3824 insertion_index += len; |
3827 } | 3825 } |
3828 | 3826 |
3829 DCHECK_EQ(insertion_index, result_len); | 3827 DCHECK_EQ(insertion_index, result_len); |
3830 return result_array; | 3828 return result_array; |
3831 } | 3829 } |
3832 | 3830 |
3833 ElementsAccessor** ElementsAccessor::elements_accessors_ = NULL; | 3831 ElementsAccessor** ElementsAccessor::elements_accessors_ = NULL; |
3834 } // namespace internal | 3832 } // namespace internal |
3835 } // namespace v8 | 3833 } // namespace v8 |
OLD | NEW |