Index: src/elements.cc |
diff --git a/src/elements.cc b/src/elements.cc |
index 78dba8567ba2d3316637da0082b9a7b878fccc7e..9deef60619312c58e03cca5d3f8e9c63aff54dfa 100644 |
--- a/src/elements.cc |
+++ b/src/elements.cc |
@@ -1985,35 +1985,26 @@ MUST_USE_RESULT MaybeObject* ArrayConstructInitializeElements( |
if (obj->IsSmi()) { |
int len = Smi::cast(obj)->value(); |
if (len > 0 && len < JSObject::kInitialMaxFastElementArray) { |
- FixedArrayBase* fixed_array; |
ElementsKind elements_kind = array->GetElementsKind(); |
- { |
- MaybeObject* maybe_obj; |
- if (IsFastDoubleElementsKind(elements_kind)) { |
- maybe_obj = heap->AllocateFixedDoubleArrayWithHoles(len); |
- } else { |
- maybe_obj = heap->AllocateFixedArrayWithHoles(len); |
- } |
- if (!maybe_obj->To(&fixed_array)) return maybe_obj; |
- } |
+ MaybeObject* maybe_array = array->Initialize(len, len); |
+ if (maybe_array->IsFailure()) return maybe_array; |
+ |
if (!IsFastHoleyElementsKind(elements_kind)) { |
elements_kind = GetHoleyElementsKind(elements_kind); |
- MaybeObject* maybe_array = |
- array->TransitionElementsKind(elements_kind); |
+ maybe_array = array->TransitionElementsKind(elements_kind); |
if (maybe_array->IsFailure()) return maybe_array; |
} |
- // We do not use SetContent to skip the unnecessary elements type check. |
- array->set_elements(fixed_array); |
- array->set_length(Smi::cast(obj)); |
+ |
return array; |
} else if (len == 0) { |
return array->Initialize(JSArray::kPreallocatedArrayElements); |
} |
} |
+ |
// Take the argument as the length. |
- { MaybeObject* maybe_obj = array->Initialize(0); |
- if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
- } |
+ MaybeObject* maybe_obj = array->Initialize(0); |
+ if (!maybe_obj->To(&obj)) return maybe_obj; |
+ |
return array->SetElementsLength((*args)[0]); |
} |
@@ -2029,7 +2020,6 @@ MUST_USE_RESULT MaybeObject* ArrayConstructInitializeElements( |
ALLOW_CONVERTED_DOUBLE_ELEMENTS); |
if (maybe_object->IsFailure()) return maybe_object; |
- |
// Allocate an appropriately typed elements array. |
MaybeObject* maybe_elms; |
ElementsKind elements_kind = array->GetElementsKind(); |