Revision: 24018
Author:   [email protected]
Date:     Thu Sep 18 06:57:12 2014 UTC
Log:      Revert "Don't use OwnPrototypeChainLength in GetOwnPropertyNames"

This reverts commit r23997 for causing check failures in
layout tests:
http://build.chromium.org/p/client.v8/builders/V8-Blink%20Linux%2064%20%28dbg%29/builds/498

[email protected]

Review URL: https://codereview.chromium.org/581013003
https://code.google.com/p/v8/source/detail?r=24018

Modified:
 /branches/bleeding_edge/src/objects.cc
 /branches/bleeding_edge/src/objects.h
 /branches/bleeding_edge/src/runtime.cc

=======================================
--- /branches/bleeding_edge/src/objects.cc      Wed Sep 17 09:56:51 2014 UTC
+++ /branches/bleeding_edge/src/objects.cc      Thu Sep 18 06:57:12 2014 UTC
@@ -13346,24 +13346,23 @@
 // Fill in the names of own properties into the supplied storage. The main
// purpose of this function is to provide reflection information for the object
 // mirrors.
-int JSObject::GetOwnPropertyNames(FixedArray* storage, int index,
-                                  PropertyAttributes filter) {
+void JSObject::GetOwnPropertyNames(
+    FixedArray* storage, int index, PropertyAttributes filter) {
   DCHECK(storage->length() >= (NumberOfOwnProperties(filter) - index));
   if (HasFastProperties()) {
-    int offset = 0;
     int real_size = map()->NumberOfOwnDescriptors();
     DescriptorArray* descs = map()->instance_descriptors();
     for (int i = 0; i < real_size; i++) {
       if ((descs->GetDetails(i).attributes() & filter) == 0 &&
           !FilterKey(descs->GetKey(i), filter)) {
-        storage->set(index + offset, descs->GetKey(i));
-        offset++;
+        storage->set(index++, descs->GetKey(i));
       }
     }
-    return offset;
   } else {
-    return property_dictionary()->CopyKeysTo(storage, index, filter,
-                                             NameDictionary::UNSORTED);
+    property_dictionary()->CopyKeysTo(storage,
+                                      index,
+                                      filter,
+                                      NameDictionary::UNSORTED);
   }
 }

@@ -14056,11 +14055,13 @@
 HashTable<SeededNumberDictionary, SeededNumberDictionaryShape, uint32_t>::
     Shrink(Handle<SeededNumberDictionary>, uint32_t);

-template int
- Dictionary<NameDictionary, NameDictionaryShape, Handle<Name>
::CopyKeysTo(
-        FixedArray*, int, PropertyAttributes,
-        Dictionary<NameDictionary, NameDictionaryShape,
-                   Handle<Name> >::SortMode);
+template void Dictionary<NameDictionary, NameDictionaryShape, Handle<Name>
::
+    CopyKeysTo(
+        FixedArray*,
+        int,
+        PropertyAttributes,
+        Dictionary<
+            NameDictionary, NameDictionaryShape, Handle<Name> >::SortMode);

 template int
 Dictionary<NameDictionary, NameDictionaryShape, Handle<Name> >::
@@ -15207,28 +15208,27 @@
 }


-template <typename Derived, typename Shape, typename Key>
-int Dictionary<Derived, Shape, Key>::CopyKeysTo(
-    FixedArray* storage, int index, PropertyAttributes filter,
+template<typename Derived, typename Shape, typename Key>
+void Dictionary<Derived, Shape, Key>::CopyKeysTo(
+    FixedArray* storage,
+    int index,
+    PropertyAttributes filter,
     typename Dictionary<Derived, Shape, Key>::SortMode sort_mode) {
   DCHECK(storage->length() >= NumberOfElementsFilterAttributes(filter));
   int capacity = DerivedHashTable::Capacity();
-  int offset = 0;
   for (int i = 0; i < capacity; i++) {
     Object* k = DerivedHashTable::KeyAt(i);
     if (DerivedHashTable::IsKey(k) && !FilterKey(k, filter)) {
       PropertyDetails details = DetailsAt(i);
       if (details.IsDeleted()) continue;
       PropertyAttributes attr = details.attributes();
-      if ((attr & filter) == 0) storage->set(index + offset, k);
-      offset++;
+      if ((attr & filter) == 0) storage->set(index++, k);
     }
   }
   if (sort_mode == Dictionary::SORTED) {
-    storage->SortPairs(storage, index + offset);
+    storage->SortPairs(storage, index);
   }
-  DCHECK(storage->length() >= index + offset);
-  return offset;
+  DCHECK(storage->length() >= index);
 }


=======================================
--- /branches/bleeding_edge/src/objects.h       Wed Sep 17 09:56:51 2014 UTC
+++ /branches/bleeding_edge/src/objects.h       Thu Sep 18 06:57:12 2014 UTC
@@ -2328,9 +2328,9 @@
   // with the specified attributes (ignoring interceptors).
   int NumberOfOwnProperties(PropertyAttributes filter = NONE);
   // Fill in details for properties into storage starting at the specified
-  // index. Returns the number of properties that were added.
-  int GetOwnPropertyNames(FixedArray* storage, int index,
-                          PropertyAttributes filter = NONE);
+  // index.
+  void GetOwnPropertyNames(
+      FixedArray* storage, int index, PropertyAttributes filter = NONE);

// Returns the number of properties on this object filtering out properties
   // with the specified attributes (ignoring interceptors).
@@ -3863,8 +3863,10 @@
                   PropertyAttributes filter,
                   SortMode sort_mode);
   // Fill in details for properties into storage.
-  int CopyKeysTo(FixedArray* storage, int index, PropertyAttributes filter,
-                 SortMode sort_mode);
+  void CopyKeysTo(FixedArray* storage,
+                  int index,
+                  PropertyAttributes filter,
+                  SortMode sort_mode);

   // Accessors for next enumeration index.
   void SetNextEnumerationIndex(int index) {
=======================================
--- /branches/bleeding_edge/src/runtime.cc      Wed Sep 17 15:29:42 2014 UTC
+++ /branches/bleeding_edge/src/runtime.cc      Thu Sep 18 06:57:12 2014 UTC
@@ -5751,6 +5751,19 @@

   return *content;
 }
+
+
+// Find the length of the prototype chain that is to be handled as one. If a +// prototype object is hidden it is to be viewed as part of the the object it
+// is prototype for.
+static int OwnPrototypeChainLength(JSObject* obj) {
+  int count = 1;
+  for (PrototypeIterator iter(obj->GetIsolate(), obj);
+ !iter.IsAtEnd(PrototypeIterator::END_AT_NON_HIDDEN); iter.Advance()) {
+    count++;
+  }
+  return count;
+}


 // Return the names of the own named properties.
@@ -5766,12 +5779,30 @@
   CONVERT_SMI_ARG_CHECKED(filter_value, 1);
PropertyAttributes filter = static_cast<PropertyAttributes>(filter_value);

+ // Skip the global proxy as it has no properties and always delegates to the
+  // real global object.
+  if (obj->IsJSGlobalProxy()) {
+    // Only collect names if access is permitted.
+    if (obj->IsAccessCheckNeeded() &&
+        !isolate->MayNamedAccess(
+            obj, isolate->factory()->undefined_value(), v8::ACCESS_KEYS)) {
+      isolate->ReportFailedAccessCheck(obj, v8::ACCESS_KEYS);
+      RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate);
+      return *isolate->factory()->NewJSArray(0);
+    }
+    PrototypeIterator iter(isolate, obj);
+    obj = Handle<JSObject>::cast(PrototypeIterator::GetCurrent(iter));
+  }
+
+  // Find the number of objects making up this.
+  int length = OwnPrototypeChainLength(*obj);
+
   // Find the number of own properties for each of the objects.
+  ScopedVector<int> own_property_count(length);
   int total_property_count = 0;
   {
PrototypeIterator iter(isolate, obj, PrototypeIterator::START_AT_RECEIVER);
-    for (; !iter.IsAtEnd(PrototypeIterator::END_AT_NON_HIDDEN);
-         iter.Advance()) {
+    for (int i = 0; i < length; i++) {
       DCHECK(!iter.IsAtEnd());
       Handle<JSObject> jsproto =
           Handle<JSObject>::cast(PrototypeIterator::GetCurrent(iter));
@@ -5786,7 +5817,9 @@
       }
       int n;
       n = jsproto->NumberOfOwnProperties(filter);
+      own_property_count[i] = n;
       total_property_count += n;
+      iter.Advance();
     }
   }

@@ -5799,18 +5832,17 @@
   int hidden_strings = 0;
   {
PrototypeIterator iter(isolate, obj, PrototypeIterator::START_AT_RECEIVER);
-    for (; !iter.IsAtEnd(PrototypeIterator::END_AT_NON_HIDDEN);
-         iter.Advance()) {
+    for (int i = 0; i < length; i++) {
+      DCHECK(!iter.IsAtEnd());
       Handle<JSObject> jsproto =
           Handle<JSObject>::cast(PrototypeIterator::GetCurrent(iter));
-      int own_property_count =
-          jsproto->GetOwnPropertyNames(*names, next_copy_index, filter);
-      if (!jsproto.is_identical_to(obj)) {
+      jsproto->GetOwnPropertyNames(*names, next_copy_index, filter);
+      if (i > 0) {
         // Names from hidden prototypes may already have been added
         // for inherited function template instances. Count the duplicates
         // and stub them out; the final copy pass at the end ignores holes.
- for (int j = next_copy_index; j < next_copy_index + own_property_count;
-             j++) {
+        for (int j = next_copy_index;
+             j < next_copy_index + own_property_count[i]; j++) {
           Object* name_from_hidden_proto = names->get(j);
           for (int k = 0; k < next_copy_index; k++) {
             if (names->get(k) != isolate->heap()->hidden_string()) {
@@ -5824,12 +5856,13 @@
           }
         }
       }
-      next_copy_index += own_property_count;
+      next_copy_index += own_property_count[i];

// Hidden properties only show up if the filter does not skip strings. if ((filter & STRING) == 0 && JSObject::HasHiddenProperties(jsproto)) {
         hidden_strings++;
       }
+      iter.Advance();
     }
   }

--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to