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

Unified Diff: src/objects.h

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/factory.cc ('k') | src/objects.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects.h
diff --git a/src/objects.h b/src/objects.h
index 4cbf2bd75d5f73d871c89e0be423321254c1f444..9da3694d81574ae29cb5219478d2a937e0a86aa7 100644
--- a/src/objects.h
+++ b/src/objects.h
@@ -2475,6 +2475,7 @@ class DescriptorArray: public FixedArray {
}
inline int number_of_entries() { return number_of_descriptors(); }
+ inline int NextEnumerationIndex() { return number_of_descriptors() + 1; }
int LastAdded() {
ASSERT(!IsEmpty());
@@ -2487,19 +2488,18 @@ class DescriptorArray: public FixedArray {
}
}
- int NextEnumerationIndex() {
- if (number_of_descriptors() == 0) {
- return PropertyDetails::kInitialIndex;
- }
- return GetDetails(LastAdded()).index() + 1;
- }
-
// Set index of the last added descriptor and flush any enum cache.
void SetLastAdded(int index) {
ASSERT(!IsEmpty() || index > 0);
set(kLastAddedIndex, Smi::FromInt(index));
}
+ int NumberOfSetDescriptors() {
+ ASSERT(!IsEmpty());
+ if (LastAdded() == kNoneAdded) return 0;
+ return GetDetails(LastAdded()).index();
+ }
+
bool HasEnumCache() {
return !IsEmpty() && !get(kLastAddedIndex)->IsSmi();
}
@@ -2546,6 +2546,11 @@ class DescriptorArray: public FixedArray {
inline void Set(int descriptor_number,
Descriptor* desc,
const WhitenessWitness&);
+ // Append automatically sets the enumeration index. This should only be used
+ // to add descriptors in bulk at the end, followed by sorting the descriptor
+ // array.
+ inline void Append(Descriptor* desc,
+ const WhitenessWitness&);
// Transfer a complete descriptor from the src descriptor array to the dst
// one, dropping map transitions in CALLBACKS.
@@ -2613,6 +2618,9 @@ class DescriptorArray: public FixedArray {
// Constant for denoting key was not found.
static const int kNotFound = -1;
+ // Constant for denoting that the LastAdded field was not yet set.
+ static const int kNoneAdded = -1;
+
static const int kBackPointerStorageIndex = 0;
static const int kLastAddedIndex = 1;
static const int kTransitionsIndex = 2;
« no previous file with comments | « src/factory.cc ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698