| 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 3681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3692 } | 3692 } |
| 3693 | 3693 |
| 3694 | 3694 |
| 3695 MaybeHandle<Object> ArrayConstructInitializeElements(Handle<JSArray> array, | 3695 MaybeHandle<Object> ArrayConstructInitializeElements(Handle<JSArray> array, |
| 3696 Arguments* args) { | 3696 Arguments* args) { |
| 3697 if (args->length() == 0) { | 3697 if (args->length() == 0) { |
| 3698 // Optimize the case where there are no parameters passed. | 3698 // Optimize the case where there are no parameters passed. |
| 3699 JSArray::Initialize(array, JSArray::kPreallocatedArrayElements); | 3699 JSArray::Initialize(array, JSArray::kPreallocatedArrayElements); |
| 3700 return array; | 3700 return array; |
| 3701 | 3701 |
| 3702 } else if (args->length() == 1 && args->at<Object>(0)->IsNumber()) { | 3702 } else if (args->length() == 1 && args->at(0)->IsNumber()) { |
| 3703 uint32_t length; | 3703 uint32_t length; |
| 3704 if (!args->at<Object>(0)->ToArrayLength(&length)) { | 3704 if (!args->at(0)->ToArrayLength(&length)) { |
| 3705 return ThrowArrayLengthRangeError(array->GetIsolate()); | 3705 return ThrowArrayLengthRangeError(array->GetIsolate()); |
| 3706 } | 3706 } |
| 3707 | 3707 |
| 3708 // Optimize the case where there is one argument and the argument is a small | 3708 // Optimize the case where there is one argument and the argument is a small |
| 3709 // smi. | 3709 // smi. |
| 3710 if (length > 0 && length < JSArray::kInitialMaxFastElementArray) { | 3710 if (length > 0 && length < JSArray::kInitialMaxFastElementArray) { |
| 3711 ElementsKind elements_kind = array->GetElementsKind(); | 3711 ElementsKind elements_kind = array->GetElementsKind(); |
| 3712 JSArray::Initialize(array, length, length); | 3712 JSArray::Initialize(array, length, length); |
| 3713 | 3713 |
| 3714 if (!IsFastHoleyElementsKind(elements_kind)) { | 3714 if (!IsFastHoleyElementsKind(elements_kind)) { |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3853 insertion_index += len; | 3853 insertion_index += len; |
| 3854 } | 3854 } |
| 3855 | 3855 |
| 3856 DCHECK_EQ(insertion_index, result_len); | 3856 DCHECK_EQ(insertion_index, result_len); |
| 3857 return result_array; | 3857 return result_array; |
| 3858 } | 3858 } |
| 3859 | 3859 |
| 3860 ElementsAccessor** ElementsAccessor::elements_accessors_ = NULL; | 3860 ElementsAccessor** ElementsAccessor::elements_accessors_ = NULL; |
| 3861 } // namespace internal | 3861 } // namespace internal |
| 3862 } // namespace v8 | 3862 } // namespace v8 |
| OLD | NEW |