| Index: src/objects.cc
|
| diff --git a/src/objects.cc b/src/objects.cc
|
| index 1e90868bc4e11088c9c6ba56954e0cfd78826bfe..c9887679b78a1d9edfde3fb20edb91cdadc72a52 100644
|
| --- a/src/objects.cc
|
| +++ b/src/objects.cc
|
| @@ -8683,23 +8683,25 @@ MaybeObject* JSObject::SetFastDoubleElementsCapacityAndLength(
|
| FixedArrayBase* old_elements = elements();
|
| ElementsKind elements_kind(GetElementsKind());
|
| AssertNoAllocation no_gc;
|
| - switch (elements_kind) {
|
| - case FAST_SMI_ONLY_ELEMENTS:
|
| - case FAST_ELEMENTS: {
|
| - elems->Initialize(FixedArray::cast(old_elements));
|
| - break;
|
| - }
|
| - case FAST_DOUBLE_ELEMENTS: {
|
| - elems->Initialize(FixedDoubleArray::cast(old_elements));
|
| - break;
|
| - }
|
| - case DICTIONARY_ELEMENTS: {
|
| - elems->Initialize(SeededNumberDictionary::cast(old_elements));
|
| - break;
|
| + if (old_elements->length() != 0) {
|
| + switch (elements_kind) {
|
| + case FAST_SMI_ONLY_ELEMENTS:
|
| + case FAST_ELEMENTS: {
|
| + elems->Initialize(FixedArray::cast(old_elements));
|
| + break;
|
| + }
|
| + case FAST_DOUBLE_ELEMENTS: {
|
| + elems->Initialize(FixedDoubleArray::cast(old_elements));
|
| + break;
|
| + }
|
| + case DICTIONARY_ELEMENTS: {
|
| + elems->Initialize(SeededNumberDictionary::cast(old_elements));
|
| + break;
|
| + }
|
| + default:
|
| + UNREACHABLE();
|
| + break;
|
| }
|
| - default:
|
| - UNREACHABLE();
|
| - break;
|
| }
|
|
|
| if (FLAG_trace_elements_transitions) {
|
| @@ -9643,13 +9645,14 @@ MUST_USE_RESULT MaybeObject* JSObject::SetFastDoubleElement(
|
| bool check_prototype) {
|
| ASSERT(HasFastDoubleElements());
|
|
|
| - FixedDoubleArray* elms = FixedDoubleArray::cast(elements());
|
| - uint32_t elms_length = static_cast<uint32_t>(elms->length());
|
| + FixedArrayBase* base_elms = FixedArrayBase::cast(elements());
|
| + uint32_t elms_length = static_cast<uint32_t>(base_elms->length());
|
|
|
| // If storing to an element that isn't in the array, pass the store request
|
| // up the prototype chain before storing in the receiver's elements.
|
| if (check_prototype &&
|
| - (index >= elms_length || elms->is_the_hole(index))) {
|
| + (index >= elms_length ||
|
| + FixedDoubleArray::cast(base_elms)->is_the_hole(index))) {
|
| bool found;
|
| MaybeObject* result = SetElementWithCallbackSetterInPrototypes(index,
|
| value,
|
| @@ -9684,6 +9687,7 @@ MUST_USE_RESULT MaybeObject* JSObject::SetFastDoubleElement(
|
|
|
| // Check whether there is extra space in the fixed array.
|
| if (index < elms_length) {
|
| + FixedDoubleArray* elms = FixedDoubleArray::cast(elements());
|
| elms->set(index, double_value);
|
| if (IsJSArray()) {
|
| // Update the length of the array if needed.
|
|
|