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/messages.h" | 10 #include "src/messages.h" |
(...skipping 2152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2163 return array; | 2163 return array; |
2164 | 2164 |
2165 } else if (args->length() == 1 && args->at<Object>(0)->IsNumber()) { | 2165 } else if (args->length() == 1 && args->at<Object>(0)->IsNumber()) { |
2166 uint32_t length; | 2166 uint32_t length; |
2167 if (!args->at<Object>(0)->ToArrayLength(&length)) { | 2167 if (!args->at<Object>(0)->ToArrayLength(&length)) { |
2168 return ThrowArrayLengthRangeError(array->GetIsolate()); | 2168 return ThrowArrayLengthRangeError(array->GetIsolate()); |
2169 } | 2169 } |
2170 | 2170 |
2171 // Optimize the case where there is one argument and the argument is a small | 2171 // Optimize the case where there is one argument and the argument is a small |
2172 // smi. | 2172 // smi. |
2173 if (length > 0 && length < JSObject::kInitialMaxFastElementArray) { | 2173 if (length > 0 && length < JSArray::kInitialMaxFastElementArray) { |
2174 ElementsKind elements_kind = array->GetElementsKind(); | 2174 ElementsKind elements_kind = array->GetElementsKind(); |
2175 JSArray::Initialize(array, length, length); | 2175 JSArray::Initialize(array, length, length); |
2176 | 2176 |
2177 if (!IsFastHoleyElementsKind(elements_kind)) { | 2177 if (!IsFastHoleyElementsKind(elements_kind)) { |
2178 elements_kind = GetHoleyElementsKind(elements_kind); | 2178 elements_kind = GetHoleyElementsKind(elements_kind); |
2179 JSObject::TransitionElementsKind(array, elements_kind); | 2179 JSObject::TransitionElementsKind(array, elements_kind); |
2180 } | 2180 } |
2181 } else if (length == 0) { | 2181 } else if (length == 0) { |
2182 JSArray::Initialize(array, JSArray::kPreallocatedArrayElements); | 2182 JSArray::Initialize(array, JSArray::kPreallocatedArrayElements); |
2183 } else { | 2183 } else { |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2326 } | 2326 } |
2327 } | 2327 } |
2328 | 2328 |
2329 DCHECK(j == result_len); | 2329 DCHECK(j == result_len); |
2330 return result_array; | 2330 return result_array; |
2331 } | 2331 } |
2332 | 2332 |
2333 ElementsAccessor** ElementsAccessor::elements_accessors_ = NULL; | 2333 ElementsAccessor** ElementsAccessor::elements_accessors_ = NULL; |
2334 } // namespace internal | 2334 } // namespace internal |
2335 } // namespace v8 | 2335 } // namespace v8 |
OLD | NEW |