| 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 866 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 877 // Check whether the backing store should be shrunk. | 877 // Check whether the backing store should be shrunk. |
| 878 if (length <= old_capacity) { | 878 if (length <= old_capacity) { |
| 879 if (array->HasFastSmiOrObjectElements()) { | 879 if (array->HasFastSmiOrObjectElements()) { |
| 880 backing_store = JSObject::EnsureWritableFastElements(array); | 880 backing_store = JSObject::EnsureWritableFastElements(array); |
| 881 } | 881 } |
| 882 if (2 * length <= old_capacity) { | 882 if (2 * length <= old_capacity) { |
| 883 // If more than half the elements won't be used, trim the array. | 883 // If more than half the elements won't be used, trim the array. |
| 884 if (length == 0) { | 884 if (length == 0) { |
| 885 array->initialize_elements(); | 885 array->initialize_elements(); |
| 886 } else { | 886 } else { |
| 887 isolate->heap()->RightTrimFixedArray<Heap::FROM_MUTATOR>( | 887 isolate->heap()->RightTrimFixedArray<Heap::CONCURRENT_TO_SWEEPER>( |
| 888 *backing_store, old_capacity - length); | 888 *backing_store, old_capacity - length); |
| 889 } | 889 } |
| 890 } else { | 890 } else { |
| 891 // Otherwise, fill the unused tail with holes. | 891 // Otherwise, fill the unused tail with holes. |
| 892 int old_length = FastD2IChecked(array->length()->Number()); | 892 int old_length = FastD2IChecked(array->length()->Number()); |
| 893 for (int i = length; i < old_length; i++) { | 893 for (int i = length; i < old_length; i++) { |
| 894 Handle<BackingStore>::cast(backing_store)->set_the_hole(i); | 894 Handle<BackingStore>::cast(backing_store)->set_the_hole(i); |
| 895 } | 895 } |
| 896 } | 896 } |
| 897 return length_object; | 897 return length_object; |
| (...skipping 945 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1843 UNREACHABLE(); | 1843 UNREACHABLE(); |
| 1844 break; | 1844 break; |
| 1845 } | 1845 } |
| 1846 | 1846 |
| 1847 array->set_elements(*elms); | 1847 array->set_elements(*elms); |
| 1848 array->set_length(Smi::FromInt(number_of_elements)); | 1848 array->set_length(Smi::FromInt(number_of_elements)); |
| 1849 return array; | 1849 return array; |
| 1850 } | 1850 } |
| 1851 | 1851 |
| 1852 } } // namespace v8::internal | 1852 } } // namespace v8::internal |
| OLD | NEW |