| 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 1825 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1836 if (len > 0 && len < JSObject::kInitialMaxFastElementArray) { | 1836 if (len > 0 && len < JSObject::kInitialMaxFastElementArray) { |
| 1837 ElementsKind elements_kind = array->GetElementsKind(); | 1837 ElementsKind elements_kind = array->GetElementsKind(); |
| 1838 JSArray::Initialize(array, len, len); | 1838 JSArray::Initialize(array, len, len); |
| 1839 | 1839 |
| 1840 if (!IsFastHoleyElementsKind(elements_kind)) { | 1840 if (!IsFastHoleyElementsKind(elements_kind)) { |
| 1841 elements_kind = GetHoleyElementsKind(elements_kind); | 1841 elements_kind = GetHoleyElementsKind(elements_kind); |
| 1842 JSObject::TransitionElementsKind(array, elements_kind); | 1842 JSObject::TransitionElementsKind(array, elements_kind); |
| 1843 } | 1843 } |
| 1844 return array; | 1844 return array; |
| 1845 } else if (len == 0) { | 1845 } else if (len == 0) { |
| 1846 JSArray::Initialize(array, JSArray::kPreallocatedArrayElements); | 1846 JSArray::Initialize(array, JSArray::PreallocatedArrayElements()); |
| 1847 return array; | 1847 return array; |
| 1848 } | 1848 } |
| 1849 } | 1849 } |
| 1850 | 1850 |
| 1851 // Take the argument as the length. | 1851 // Take the argument as the length. |
| 1852 JSArray::Initialize(array, 0); | 1852 JSArray::Initialize(array, 0); |
| 1853 | 1853 |
| 1854 return JSArray::SetElementsLength(array, obj); | 1854 return JSArray::SetElementsLength(array, obj); |
| 1855 } | 1855 } |
| 1856 | 1856 |
| 1857 // Optimize the case where there are no parameters passed. | 1857 // Optimize the case where there are no parameters passed. |
| 1858 if (args->length() == 0) { | 1858 if (args->length() == 0) { |
| 1859 JSArray::Initialize(array, JSArray::kPreallocatedArrayElements); | 1859 JSArray::Initialize(array, JSArray::PreallocatedArrayElements()); |
| 1860 return array; | 1860 return array; |
| 1861 } | 1861 } |
| 1862 | 1862 |
| 1863 Factory* factory = array->GetIsolate()->factory(); | 1863 Factory* factory = array->GetIsolate()->factory(); |
| 1864 | 1864 |
| 1865 // Set length and elements on the array. | 1865 // Set length and elements on the array. |
| 1866 int number_of_elements = args->length(); | 1866 int number_of_elements = args->length(); |
| 1867 JSObject::EnsureCanContainElements( | 1867 JSObject::EnsureCanContainElements( |
| 1868 array, args, 0, number_of_elements, ALLOW_CONVERTED_DOUBLE_ELEMENTS); | 1868 array, args, 0, number_of_elements, ALLOW_CONVERTED_DOUBLE_ELEMENTS); |
| 1869 | 1869 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1911 UNREACHABLE(); | 1911 UNREACHABLE(); |
| 1912 break; | 1912 break; |
| 1913 } | 1913 } |
| 1914 | 1914 |
| 1915 array->set_elements(*elms); | 1915 array->set_elements(*elms); |
| 1916 array->set_length(Smi::FromInt(number_of_elements)); | 1916 array->set_length(Smi::FromInt(number_of_elements)); |
| 1917 return array; | 1917 return array; |
| 1918 } | 1918 } |
| 1919 | 1919 |
| 1920 } } // namespace v8::internal | 1920 } } // namespace v8::internal |
| OLD | NEW |