| Index: src/objects.cc
|
| diff --git a/src/objects.cc b/src/objects.cc
|
| index 9726f1af12a6b4651a94551548d22607fbe7c5e5..c8694d78dca87bd71526ce954dfbba39d38335f8 100644
|
| --- a/src/objects.cc
|
| +++ b/src/objects.cc
|
| @@ -5801,7 +5801,7 @@ MaybeObject* DescriptorArray::Allocate(int number_of_descriptors,
|
| if (!maybe_array->To(&result)) return maybe_array;
|
| }
|
|
|
| - result->set(kLastAddedIndex, Smi::FromInt(-1));
|
| + result->set(kLastAddedIndex, Smi::FromInt(kNoneAdded));
|
| result->set(kTransitionsIndex, Smi::FromInt(0));
|
| return result;
|
| }
|
| @@ -5928,7 +5928,8 @@ MaybeObject* DescriptorArray::CopyAdd(Descriptor* descriptor) {
|
|
|
| FixedArray::WhitenessWitness witness(new_descriptors);
|
|
|
| - descriptor->SetEnumerationIndex(NextEnumerationIndex());
|
| + ASSERT(new_size == NextEnumerationIndex());
|
| + descriptor->SetEnumerationIndex(new_size);
|
|
|
| // Copy the descriptors, inserting or replacing a descriptor.
|
| int insertion_index = -1;
|
| @@ -5988,6 +5989,9 @@ void DescriptorArray::SortUnchecked(const WhitenessWitness& witness) {
|
| // Nothing to sort.
|
| if (len == 0) return;
|
|
|
| + ASSERT(LastAdded() == kNoneAdded ||
|
| + GetDetails(LastAdded()).index() == number_of_descriptors());
|
| +
|
| // Bottom-up max-heap construction.
|
| // Index of the last node with children
|
| const int max_parent_index = (len / 2) - 1;
|
| @@ -6035,18 +6039,29 @@ void DescriptorArray::SortUnchecked(const WhitenessWitness& witness) {
|
| }
|
| }
|
|
|
| - int last_enum_index = -1;
|
| - int last_added = -1;
|
| +#ifdef DEBUG
|
| + // Ensure that all enumeration indexes between 1 and length occur uniquely in
|
| + // the descriptor array.
|
| + for (int i = 1; i <= len; ++i) {
|
| + int j;
|
| + for (j = 0; j < len; ++j) {
|
| + if (GetDetails(j).index() == i) break;
|
| + }
|
| + ASSERT(j != len);
|
| + for (j++; j < len; ++j) {
|
| + ASSERT(GetDetails(j).index() != i);
|
| + }
|
| + }
|
| +#endif
|
| +
|
| for (int i = 0; i < len; ++i) {
|
| - int current_enum = GetDetails(i).index();
|
| - if (current_enum > last_enum_index) {
|
| - last_added = i;
|
| - last_enum_index = current_enum;
|
| + if (GetDetails(i).index() == len) {
|
| + SetLastAdded(i);
|
| + return;
|
| }
|
| }
|
| - SetLastAdded(last_added);
|
|
|
| - ASSERT(LastAdded() != -1);
|
| + UNREACHABLE();
|
| }
|
|
|
|
|
|
|