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

Side by Side Diff: src/objects.cc

Issue 1146913002: Change hash table capacity defaults. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 7 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.h ('k') | 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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 #include <iomanip> 5 #include <iomanip>
6 #include <sstream> 6 #include <sstream>
7 7
8 #include "src/v8.h" 8 #include "src/v8.h"
9 9
10 #include "src/accessors.h" 10 #include "src/accessors.h"
(...skipping 14864 matching lines...) Expand 10 before | Expand all | Expand 10 after
14875 // at most 50% of the free elements are deleted elements. 14875 // at most 50% of the free elements are deleted elements.
14876 if (nod <= (capacity - nof) >> 1) { 14876 if (nod <= (capacity - nof) >> 1) {
14877 int needed_free = nof >> 1; 14877 int needed_free = nof >> 1;
14878 if (nof + needed_free <= capacity) return table; 14878 if (nof + needed_free <= capacity) return table;
14879 } 14879 }
14880 14880
14881 const int kMinCapacityForPretenure = 256; 14881 const int kMinCapacityForPretenure = 256;
14882 bool should_pretenure = pretenure == TENURED || 14882 bool should_pretenure = pretenure == TENURED ||
14883 ((capacity > kMinCapacityForPretenure) && 14883 ((capacity > kMinCapacityForPretenure) &&
14884 !isolate->heap()->InNewSpace(*table)); 14884 !isolate->heap()->InNewSpace(*table));
14885 Handle<Derived> new_table = HashTable::New( 14885 Handle<Derived> new_table =
14886 isolate, 14886 HashTable::New(isolate, nof * 2, USE_COMPUTED_MINIMUM_CAPACITY,
14887 nof * 2, 14887 should_pretenure ? TENURED : NOT_TENURED);
14888 USE_DEFAULT_MINIMUM_CAPACITY,
14889 should_pretenure ? TENURED : NOT_TENURED);
14890 14888
14891 table->Rehash(new_table, key); 14889 table->Rehash(new_table, key);
14892 return new_table; 14890 return new_table;
14893 } 14891 }
14894 14892
14895 14893
14896 template<typename Derived, typename Shape, typename Key> 14894 template<typename Derived, typename Shape, typename Key>
14897 Handle<Derived> HashTable<Derived, Shape, Key>::Shrink(Handle<Derived> table, 14895 Handle<Derived> HashTable<Derived, Shape, Key>::Shrink(Handle<Derived> table,
14898 Key key) { 14896 Key key) {
14899 int capacity = table->Capacity(); 14897 int capacity = table->Capacity();
14900 int nof = table->NumberOfElements(); 14898 int nof = table->NumberOfElements();
14901 14899
14902 // Shrink to fit the number of elements if only a quarter of the 14900 // Shrink to fit the number of elements if only a quarter of the
14903 // capacity is filled with elements. 14901 // capacity is filled with elements.
14904 if (nof > (capacity >> 2)) return table; 14902 if (nof > (capacity >> 2)) return table;
14905 // Allocate a new dictionary with room for at least the current 14903 // Allocate a new dictionary with room for at least the current
14906 // number of elements. The allocation method will make sure that 14904 // number of elements. The allocation method will make sure that
14907 // there is extra room in the dictionary for additions. Don't go 14905 // there is extra room in the dictionary for additions. Don't go
14908 // lower than room for 16 elements. 14906 // lower than room for 16 elements.
14909 int at_least_room_for = nof; 14907 int at_least_room_for = nof;
14910 if (at_least_room_for < 16) return table; 14908 if (at_least_room_for < 16) return table;
14911 14909
14912 Isolate* isolate = table->GetIsolate(); 14910 Isolate* isolate = table->GetIsolate();
14913 const int kMinCapacityForPretenure = 256; 14911 const int kMinCapacityForPretenure = 256;
14914 bool pretenure = 14912 bool pretenure =
14915 (at_least_room_for > kMinCapacityForPretenure) && 14913 (at_least_room_for > kMinCapacityForPretenure) &&
14916 !isolate->heap()->InNewSpace(*table); 14914 !isolate->heap()->InNewSpace(*table);
14917 Handle<Derived> new_table = HashTable::New( 14915 Handle<Derived> new_table =
14918 isolate, 14916 HashTable::New(isolate, at_least_room_for, USE_COMPUTED_MINIMUM_CAPACITY,
14919 at_least_room_for, 14917 pretenure ? TENURED : NOT_TENURED);
14920 USE_DEFAULT_MINIMUM_CAPACITY,
14921 pretenure ? TENURED : NOT_TENURED);
14922 14918
14923 table->Rehash(new_table, key); 14919 table->Rehash(new_table, key);
14924 return new_table; 14920 return new_table;
14925 } 14921 }
14926 14922
14927 14923
14928 template<typename Derived, typename Shape, typename Key> 14924 template<typename Derived, typename Shape, typename Key>
14929 uint32_t HashTable<Derived, Shape, Key>::FindInsertionEntry(uint32_t hash) { 14925 uint32_t HashTable<Derived, Shape, Key>::FindInsertionEntry(uint32_t hash) {
14930 uint32_t capacity = Capacity(); 14926 uint32_t capacity = Capacity();
14931 uint32_t entry = FirstProbe(hash, capacity); 14927 uint32_t entry = FirstProbe(hash, capacity);
(...skipping 946 matching lines...) Expand 10 before | Expand all | Expand 10 after
15878 Handle<FixedArray> strings_; 15874 Handle<FixedArray> strings_;
15879 }; 15875 };
15880 15876
15881 15877
15882 template<typename Derived, typename Shape, typename Key> 15878 template<typename Derived, typename Shape, typename Key>
15883 Handle<Derived> Dictionary<Derived, Shape, Key>::New( 15879 Handle<Derived> Dictionary<Derived, Shape, Key>::New(
15884 Isolate* isolate, 15880 Isolate* isolate,
15885 int at_least_space_for, 15881 int at_least_space_for,
15886 PretenureFlag pretenure) { 15882 PretenureFlag pretenure) {
15887 DCHECK(0 <= at_least_space_for); 15883 DCHECK(0 <= at_least_space_for);
15888 Handle<Derived> dict = DerivedHashTable::New(isolate, 15884 Handle<Derived> dict = DerivedHashTable::New(
15889 at_least_space_for, 15885 isolate, at_least_space_for, USE_COMPUTED_MINIMUM_CAPACITY, pretenure);
15890 USE_DEFAULT_MINIMUM_CAPACITY,
15891 pretenure);
15892 15886
15893 // Initialize the next enumeration index. 15887 // Initialize the next enumeration index.
15894 dict->SetNextEnumerationIndex(PropertyDetails::kInitialIndex); 15888 dict->SetNextEnumerationIndex(PropertyDetails::kInitialIndex);
15895 return dict; 15889 return dict;
15896 } 15890 }
15897 15891
15898 15892
15899 template <typename Derived, typename Shape, typename Key> 15893 template <typename Derived, typename Shape, typename Key>
15900 Handle<FixedArray> Dictionary<Derived, Shape, Key>::BuildIterationIndicesArray( 15894 Handle<FixedArray> Dictionary<Derived, Shape, Key>::BuildIterationIndicesArray(
15901 Handle<Derived> dictionary) { 15895 Handle<Derived> dictionary) {
(...skipping 1348 matching lines...) Expand 10 before | Expand all | Expand 10 after
17250 void PropertyCell::SetValueWithInvalidation(Handle<PropertyCell> cell, 17244 void PropertyCell::SetValueWithInvalidation(Handle<PropertyCell> cell,
17251 Handle<Object> new_value) { 17245 Handle<Object> new_value) {
17252 if (cell->value() != *new_value) { 17246 if (cell->value() != *new_value) {
17253 cell->set_value(*new_value); 17247 cell->set_value(*new_value);
17254 Isolate* isolate = cell->GetIsolate(); 17248 Isolate* isolate = cell->GetIsolate();
17255 cell->dependent_code()->DeoptimizeDependentCodeGroup( 17249 cell->dependent_code()->DeoptimizeDependentCodeGroup(
17256 isolate, DependentCode::kPropertyCellChangedGroup); 17250 isolate, DependentCode::kPropertyCellChangedGroup);
17257 } 17251 }
17258 } 17252 }
17259 } } // namespace v8::internal 17253 } } // namespace v8::internal
OLDNEW
« 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