Commit 996c84fb authored by verwaest@chromium.org's avatar verwaest@chromium.org

If we are trimming the whole array, just return the empty fixed array.

Review URL: https://chromiumcodereview.appspot.com/10911054

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@12427 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 3eed540a
...@@ -799,7 +799,7 @@ Handle<FixedArray> GetEnumPropertyKeys(Handle<JSObject> object, ...@@ -799,7 +799,7 @@ Handle<FixedArray> GetEnumPropertyKeys(Handle<JSObject> object,
Handle<FixedArray> storage = Handle<FixedArray> storage =
isolate->factory()->NewFixedArray(next_enumeration); isolate->factory()->NewFixedArray(next_enumeration);
dictionary->CopyEnumKeysTo(*storage); storage = Handle<FixedArray>(dictionary->CopyEnumKeysTo(*storage));
ASSERT(storage->length() == object->NumberOfLocalProperties(DONT_ENUM)); ASSERT(storage->length() == object->NumberOfLocalProperties(DONT_ENUM));
return storage; return storage;
} }
......
...@@ -12474,7 +12474,7 @@ void Dictionary<Shape, Key>::CopyKeysTo( ...@@ -12474,7 +12474,7 @@ void Dictionary<Shape, Key>::CopyKeysTo(
} }
void StringDictionary::CopyEnumKeysTo(FixedArray* storage) { FixedArray* StringDictionary::CopyEnumKeysTo(FixedArray* storage) {
int length = storage->length(); int length = storage->length();
ASSERT(length >= NumberOfEnumElements()); ASSERT(length >= NumberOfEnumElements());
Heap* heap = GetHeap(); Heap* heap = GetHeap();
...@@ -12501,6 +12501,7 @@ void StringDictionary::CopyEnumKeysTo(FixedArray* storage) { ...@@ -12501,6 +12501,7 @@ void StringDictionary::CopyEnumKeysTo(FixedArray* storage) {
// together by shifting them to the left (maintaining the enumeration order), // together by shifting them to the left (maintaining the enumeration order),
// and trimming of the right side of the array. // and trimming of the right side of the array.
if (properties < length) { if (properties < length) {
if (properties == 0) return heap->empty_fixed_array();
properties = 0; properties = 0;
for (int i = 0; i < length; ++i) { for (int i = 0; i < length; ++i) {
Object* value = storage->get(i); Object* value = storage->get(i);
...@@ -12511,6 +12512,7 @@ void StringDictionary::CopyEnumKeysTo(FixedArray* storage) { ...@@ -12511,6 +12512,7 @@ void StringDictionary::CopyEnumKeysTo(FixedArray* storage) {
} }
RightTrimFixedArray<FROM_MUTATOR>(heap, storage, length - properties); RightTrimFixedArray<FROM_MUTATOR>(heap, storage, length - properties);
} }
return storage;
} }
......
...@@ -3128,7 +3128,7 @@ class StringDictionary: public Dictionary<StringDictionaryShape, String*> { ...@@ -3128,7 +3128,7 @@ class StringDictionary: public Dictionary<StringDictionaryShape, String*> {
} }
// Copies enumerable keys to preallocated fixed array. // Copies enumerable keys to preallocated fixed array.
void CopyEnumKeysTo(FixedArray* storage); FixedArray* CopyEnumKeysTo(FixedArray* storage);
static void DoGenerateNewEnumerationIndices( static void DoGenerateNewEnumerationIndices(
Handle<StringDictionary> dictionary); Handle<StringDictionary> dictionary);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment