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

Unified Diff: src/objects.cc

Issue 661468: - Changed the initial size for HashTable.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 10 years, 10 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
« no previous file with comments | « src/objects.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects.cc
===================================================================
--- src/objects.cc (revision 4009)
+++ src/objects.cc (working copy)
@@ -6904,15 +6904,16 @@
template<typename Shape, typename Key>
-Object* HashTable<Shape, Key>::Allocate(int at_least_space_for) {
- int capacity = RoundUpToPowerOf2(at_least_space_for);
- if (capacity < 4) {
- capacity = 4; // Guarantee min capacity.
+Object* HashTable<Shape, Key>::Allocate(int at_least_space_for,
+ PretenureFlag pretenure) {
+ int capacity = RoundUpToPowerOf2(at_least_space_for * 2);
+ if (capacity < 32) {
+ capacity = 32; // Guarantee min capacity.
} else if (capacity > HashTable::kMaxCapacity) {
return Failure::OutOfMemoryException();
}
- Object* obj = Heap::AllocateHashTable(EntryToIndex(capacity));
+ Object* obj = Heap::AllocateHashTable(EntryToIndex(capacity), pretenure);
if (!obj->IsFailure()) {
HashTable::cast(obj)->SetNumberOfElements(0);
HashTable::cast(obj)->SetNumberOfDeletedElements(0);
@@ -6947,10 +6948,15 @@
// Return if:
// 25% is still free after adding n elements and
Kasper Lund 2010/03/03 16:01:06 Update comment to reflect 50%.
bak 2010/03/03 16:18:26 Done.
// at most 50% of the free elements are deleted elements.
- if ((nof + (nof >> 2) <= capacity) &&
- (nod <= (capacity - nof) >> 1)) return this;
+ if (nod <= (capacity - nof) >> 1) {
+ int needed_free = nof >> 1;
+ if (nof + needed_free <= capacity) return this;
+ }
- Object* obj = Allocate(nof * 2);
+ const int kMinCapacityForPreTenure = 256;
Kasper Lund 2010/03/03 16:01:06 PreTenure -> Pretenure (to match the rest of the c
bak 2010/03/03 16:18:26 I changed the uppercase issue.
+ bool pretenure =
+ (capacity > kMinCapacityForPreTenure) && !Heap::InNewSpace(this);
+ Object* obj = Allocate(nof * 2, pretenure ? TENURED : NOT_TENURED);
if (obj->IsFailure()) return obj;
AssertNoAllocation no_gc;
« no previous file with comments | « src/objects.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698