Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(574)

Unified Diff: src/objects.cc

Issue 10692185: Couple the enumeration index of a property to the size of the descriptor array where it first appea… (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Use the enumeration index of the LastAdded descriptor for appending. Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
}
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698