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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « src/objects.cc ('k') | test/mjsunit/ensure-growing-store-learns.js » ('j') | 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 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 // 4 //
5 // Review notes: 5 // Review notes:
6 // 6 //
7 // - The use of macros in these inline functions may seem superfluous 7 // - The use of macros in these inline functions may seem superfluous
8 // but it is absolutely needed to make sure gcc generates optimal 8 // but it is absolutely needed to make sure gcc generates optimal
9 // code. gcc is not happy when attempting to inline too deep. 9 // code. gcc is not happy when attempting to inline too deep.
10 // 10 //
(...skipping 3105 matching lines...) Expand 10 before | Expand all | Expand 10 after
3116 3116
3117 3117
3118 void HashTableBase::ElementsRemoved(int n) { 3118 void HashTableBase::ElementsRemoved(int n) {
3119 SetNumberOfElements(NumberOfElements() - n); 3119 SetNumberOfElements(NumberOfElements() - n);
3120 SetNumberOfDeletedElements(NumberOfDeletedElements() + n); 3120 SetNumberOfDeletedElements(NumberOfDeletedElements() + n);
3121 } 3121 }
3122 3122
3123 3123
3124 // static 3124 // static
3125 int HashTableBase::ComputeCapacity(int at_least_space_for) { 3125 int HashTableBase::ComputeCapacity(int at_least_space_for) {
3126 int capacity = base::bits::RoundUpToPowerOfTwo32(at_least_space_for * 2); 3126 // Add 50% slack to make slot collisions sufficiently unlikely.
3127 // See matching computation in HashTable::HasSufficientCapacityToAdd().
3128 // Must be kept in sync with CodeStubAssembler::HashTableComputeCapacity().
3129 int raw_cap = at_least_space_for + (at_least_space_for >> 1);
3130 int capacity = base::bits::RoundUpToPowerOfTwo32(raw_cap);
3127 return Max(capacity, kMinCapacity); 3131 return Max(capacity, kMinCapacity);
3128 } 3132 }
3129 3133
3130 bool HashTableBase::IsKey(Isolate* isolate, Object* k) { 3134 bool HashTableBase::IsKey(Isolate* isolate, Object* k) {
3131 Heap* heap = isolate->heap(); 3135 Heap* heap = isolate->heap();
3132 return k != heap->the_hole_value() && k != heap->undefined_value(); 3136 return k != heap->the_hole_value() && k != heap->undefined_value();
3133 } 3137 }
3134 3138
3135 void HashTableBase::SetNumberOfElements(int nof) { 3139 void HashTableBase::SetNumberOfElements(int nof) {
3136 set(kNumberOfElementsIndex, Smi::FromInt(nof)); 3140 set(kNumberOfElementsIndex, Smi::FromInt(nof));
(...skipping 5237 matching lines...) Expand 10 before | Expand all | Expand 10 after
8374 #undef WRITE_BYTE_FIELD 8378 #undef WRITE_BYTE_FIELD
8375 #undef NOBARRIER_READ_BYTE_FIELD 8379 #undef NOBARRIER_READ_BYTE_FIELD
8376 #undef NOBARRIER_WRITE_BYTE_FIELD 8380 #undef NOBARRIER_WRITE_BYTE_FIELD
8377 8381
8378 } // namespace internal 8382 } // namespace internal
8379 } // namespace v8 8383 } // namespace v8
8380 8384
8381 #include "src/objects/object-macros-undef.h" 8385 #include "src/objects/object-macros-undef.h"
8382 8386
8383 #endif // V8_OBJECTS_INL_H_ 8387 #endif // V8_OBJECTS_INL_H_
OLDNEW
« 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