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

Unified Diff: src/objects.cc

Issue 10908216: Ensure correct enumeration indices in the dict (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 3 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
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index 57882a4d20a0f8f3a64c9919c39d94c86f64df30..34d3364cfb159434827d3d7206d24b81d3b8d61f 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -487,11 +487,20 @@ MaybeObject* JSObject::SetNormalizedProperty(String* name,
set_properties(StringDictionary::cast(dict));
return value;
}
- // Preserve enumeration index.
+
+ PropertyDetails original_details = property_dictionary()->DetailsAt(entry);
+ int enumeration_index;
+ // Preserve the enumeration index unless the property was deleted.
+ if (original_details.IsDeleted()) {
+ enumeration_index = property_dictionary()->NextEnumerationIndex();
+ property_dictionary()->SetNextEnumerationIndex(enumeration_index + 1);
+ } else {
+ enumeration_index = original_details.dictionary_index();
+ ASSERT(enumeration_index != 0);
+ }
+
details = PropertyDetails(
- details.attributes(),
- details.type(),
- property_dictionary()->DetailsAt(entry).dictionary_index());
+ details.attributes(), details.type(), enumeration_index);
if (IsGlobalObject()) {
JSGlobalPropertyCell* cell =
@@ -9392,8 +9401,15 @@ MaybeObject* JSObject::SetDictionaryElement(uint32_t index,
// is read-only (a declared const that has not been initialized). If a
// value is being defined we skip attribute checks completely.
if (set_mode == DEFINE_PROPERTY) {
+ int enumeration_index;
+ if (details.dictionary_index() == 0 && !(attributes & DONT_ENUM)) {
Michael Starzinger 2012/09/12 17:06:55 Why do we check for DONT_ENUM here? Do we do that
Toon Verwaest 2012/09/13 08:46:32 You are right, this code is unnecessary for elemen
+ enumeration_index = dictionary->NextEnumerationIndex();
+ dictionary->SetNextEnumerationIndex(enumeration_index + 1);
+ } else {
+ enumeration_index = details.dictionary_index();
+ }
details = PropertyDetails(
- attributes, NORMAL, details.dictionary_index());
+ attributes, NORMAL, enumeration_index);
dictionary->DetailsAtPut(entry, details);
} else if (details.IsReadOnly() && !element->IsTheHole()) {
if (strict_mode == kNonStrictMode) {

Powered by Google App Engine
This is Rietveld 408576698