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

Side by Side Diff: src/handles.cc

Issue 10911058: Do not generate new enumeration indices for global objects. (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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 773 matching lines...) Expand 10 before | Expand all | Expand 10 after
784 // properties were not visible, the array is trimmed so it only contains 784 // properties were not visible, the array is trimmed so it only contains
785 // visible properties. This improves over adding elements and sorting by 785 // visible properties. This improves over adding elements and sorting by
786 // index by having linear complexity rather than n*log(n). 786 // index by having linear complexity rather than n*log(n).
787 787
788 // By comparing the monotonous NextEnumerationIndex to the NumberOfElements, 788 // By comparing the monotonous NextEnumerationIndex to the NumberOfElements,
789 // we can predict the number of holes in the final array. If there will be 789 // we can predict the number of holes in the final array. If there will be
790 // more than 50% holes, regenerate the enumeration indices to reduce the 790 // more than 50% holes, regenerate the enumeration indices to reduce the
791 // number of holes to a minimum. This avoids allocating a large array if 791 // number of holes to a minimum. This avoids allocating a large array if
792 // many properties were added but subsequently deleted. 792 // many properties were added but subsequently deleted.
793 int next_enumeration = dictionary->NextEnumerationIndex(); 793 int next_enumeration = dictionary->NextEnumerationIndex();
794 if (next_enumeration > (length * 3) / 2) { 794 if (!object->IsGlobalObject() && next_enumeration > (length * 3) / 2) {
795 StringDictionary::DoGenerateNewEnumerationIndices(dictionary); 795 StringDictionary::DoGenerateNewEnumerationIndices(dictionary);
796 next_enumeration = dictionary->NextEnumerationIndex(); 796 next_enumeration = dictionary->NextEnumerationIndex();
797 } 797 }
798 798
799 Handle<FixedArray> storage = 799 Handle<FixedArray> storage =
800 isolate->factory()->NewFixedArray(next_enumeration); 800 isolate->factory()->NewFixedArray(next_enumeration);
801 801
802 storage = Handle<FixedArray>(dictionary->CopyEnumKeysTo(*storage)); 802 storage = Handle<FixedArray>(dictionary->CopyEnumKeysTo(*storage));
803 ASSERT(storage->length() == object->NumberOfLocalProperties(DONT_ENUM)); 803 ASSERT(storage->length() == object->NumberOfLocalProperties(DONT_ENUM));
804 return storage; 804 return storage;
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
1026 data->next = prev_next_; 1026 data->next = prev_next_;
1027 data->limit = prev_limit_; 1027 data->limit = prev_limit_;
1028 #ifdef DEBUG 1028 #ifdef DEBUG
1029 handles_detached_ = true; 1029 handles_detached_ = true;
1030 #endif 1030 #endif
1031 return deferred; 1031 return deferred;
1032 } 1032 }
1033 1033
1034 1034
1035 } } // namespace v8::internal 1035 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698