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; |