Revision: 12427
Author:   [email protected]
Date:     Mon Sep  3 06:27:17 2012
Log: If we are trimming the whole array, just return the empty fixed array.

Review URL: https://chromiumcodereview.appspot.com/10911054
http://code.google.com/p/v8/source/detail?r=12427

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

=======================================
--- /branches/bleeding_edge/src/handles.cc      Mon Sep  3 05:31:24 2012
+++ /branches/bleeding_edge/src/handles.cc      Mon Sep  3 06:27:17 2012
@@ -799,7 +799,7 @@
     Handle<FixedArray> storage =
         isolate->factory()->NewFixedArray(next_enumeration);

-    dictionary->CopyEnumKeysTo(*storage);
+    storage = Handle<FixedArray>(dictionary->CopyEnumKeysTo(*storage));
ASSERT(storage->length() == object->NumberOfLocalProperties(DONT_ENUM));
     return storage;
   }
=======================================
--- /branches/bleeding_edge/src/objects.cc      Mon Sep  3 05:31:24 2012
+++ /branches/bleeding_edge/src/objects.cc      Mon Sep  3 06:27:17 2012
@@ -12474,7 +12474,7 @@
 }


-void StringDictionary::CopyEnumKeysTo(FixedArray* storage) {
+FixedArray* StringDictionary::CopyEnumKeysTo(FixedArray* storage) {
   int length = storage->length();
   ASSERT(length >= NumberOfEnumElements());
   Heap* heap = GetHeap();
@@ -12501,6 +12501,7 @@
// together by shifting them to the left (maintaining the enumeration order),
   // and trimming of the right side of the array.
   if (properties < length) {
+    if (properties == 0) return heap->empty_fixed_array();
     properties = 0;
     for (int i = 0; i < length; ++i) {
       Object* value = storage->get(i);
@@ -12511,6 +12512,7 @@
     }
     RightTrimFixedArray<FROM_MUTATOR>(heap, storage, length - properties);
   }
+  return storage;
 }


=======================================
--- /branches/bleeding_edge/src/objects.h       Mon Sep  3 05:31:24 2012
+++ /branches/bleeding_edge/src/objects.h       Mon Sep  3 06:27:17 2012
@@ -3128,7 +3128,7 @@
   }

   // Copies enumerable keys to preallocated fixed array.
-  void CopyEnumKeysTo(FixedArray* storage);
+  FixedArray* CopyEnumKeysTo(FixedArray* storage);
   static void DoGenerateNewEnumerationIndices(
       Handle<StringDictionary> dictionary);

--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to