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

Unified Diff: src/objects-inl.h

Issue 2827263004: Fix HashTable growth strategy to be 2x instead of 4x (Closed)
Patch Set: update CSA; fix test Created 3 years, 8 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.cc ('k') | test/mjsunit/ensure-growing-store-learns.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects-inl.h
diff --git a/src/objects-inl.h b/src/objects-inl.h
index dab11398ceb66533c6c93e712d2ea48781100cad..745be06c9edd1b6abfd3d64353386defd259f406 100644
--- a/src/objects-inl.h
+++ b/src/objects-inl.h
@@ -3123,7 +3123,11 @@ void HashTableBase::ElementsRemoved(int n) {
// static
int HashTableBase::ComputeCapacity(int at_least_space_for) {
- int capacity = base::bits::RoundUpToPowerOfTwo32(at_least_space_for * 2);
+ // Add 50% slack to make slot collisions sufficiently unlikely.
+ // See matching computation in HashTable::HasSufficientCapacityToAdd().
+ // Must be kept in sync with CodeStubAssembler::HashTableComputeCapacity().
+ int raw_cap = at_least_space_for + (at_least_space_for >> 1);
+ int capacity = base::bits::RoundUpToPowerOfTwo32(raw_cap);
return Max(capacity, kMinCapacity);
}
« no previous file with comments | « src/objects.cc ('k') | test/mjsunit/ensure-growing-store-learns.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698