Reviewers: mvstanton,
Message:
The rationale is: callsites of HashTable::New without the capacity_option
argument specify an initial size of the hash table. It's surprising that
it's
automatically doubled. This does not change the size of the slow mode object
property dictionary, as it allocates via Dictionary::New.
Description:
Change hash table capacity defaults.
BUG=chromium:481129
LOG=N
Please review this at https://codereview.chromium.org/1146913002/
Base URL: https://chromium.googlesource.com/v8/v8.git@master
Affected files (+12, -19 lines):
M src/api-natives.h
M src/globals.h
M src/heap/heap.cc
M src/objects.h
M src/objects.cc
Index: src/api-natives.h
diff --git a/src/api-natives.h b/src/api-natives.h
index
224c78a6adb421fcb62ad75394ab4af83bfaac3b..84b65bda92a18539f13ae75876a81846f086d707
100644
--- a/src/api-natives.h
+++ b/src/api-natives.h
@@ -12,7 +12,7 @@ namespace internal {
class ApiNatives {
public:
- static const int kInitialFunctionCacheSize = 256;
+ static const int kInitialFunctionCacheSize = 64;
MUST_USE_RESULT static MaybeHandle<JSFunction> InstantiateFunction(
Handle<FunctionTemplateInfo> data);
Index: src/globals.h
diff --git a/src/globals.h b/src/globals.h
index
761983178d4b0f4d2f316744eed9d4ff818474e4..152917086ecbfc5f436bf3c85c05ce2b82d09bb7
100644
--- a/src/globals.h
+++ b/src/globals.h
@@ -447,7 +447,7 @@ enum AllocationAlignment { kWordAligned,
kDoubleAligned, kDoubleUnaligned };
enum PretenureFlag { NOT_TENURED, TENURED };
enum MinimumCapacity {
- USE_DEFAULT_MINIMUM_CAPACITY,
+ USE_COMPUTED_MINIMUM_CAPACITY,
USE_CUSTOM_MINIMUM_CAPACITY
};
Index: src/heap/heap.cc
diff --git a/src/heap/heap.cc b/src/heap/heap.cc
index
99f2e93f505f78a4d3894f828083d41b42d3decd..f51ea0183b83d18b3d7f8c5527e8f49c087e3879
100644
--- a/src/heap/heap.cc
+++ b/src/heap/heap.cc
@@ -3133,8 +3133,7 @@ void Heap::CreateInitialObjects() {
set_retained_maps(ArrayList::cast(empty_fixed_array()));
set_weak_object_to_code_table(
- *WeakHashTable::New(isolate(), 16, USE_DEFAULT_MINIMUM_CAPACITY,
- TENURED));
+ *WeakHashTable::New(isolate(), 16, USE_CUSTOM_MINIMUM_CAPACITY,
TENURED));
Handle<SeededNumberDictionary> slow_element_dictionary =
SeededNumberDictionary::New(isolate(), 0, TENURED);
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index
645ea57e344d2727209c68fa90b4a98843108d0e..96115da5082a87d808deae17ddc1f0cfabb78d6e
100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -14882,11 +14882,9 @@ Handle<Derived> HashTable<Derived, Shape,
Key>::EnsureCapacity(
bool should_pretenure = pretenure == TENURED ||
((capacity > kMinCapacityForPretenure) &&
!isolate->heap()->InNewSpace(*table));
- Handle<Derived> new_table = HashTable::New(
- isolate,
- nof * 2,
- USE_DEFAULT_MINIMUM_CAPACITY,
- should_pretenure ? TENURED : NOT_TENURED);
+ Handle<Derived> new_table =
+ HashTable::New(isolate, nof * 2, USE_COMPUTED_MINIMUM_CAPACITY,
+ should_pretenure ? TENURED : NOT_TENURED);
table->Rehash(new_table, key);
return new_table;
@@ -14914,11 +14912,9 @@ Handle<Derived> HashTable<Derived, Shape,
Key>::Shrink(Handle<Derived> table,
bool pretenure =
(at_least_room_for > kMinCapacityForPretenure) &&
!isolate->heap()->InNewSpace(*table);
- Handle<Derived> new_table = HashTable::New(
- isolate,
- at_least_room_for,
- USE_DEFAULT_MINIMUM_CAPACITY,
- pretenure ? TENURED : NOT_TENURED);
+ Handle<Derived> new_table =
+ HashTable::New(isolate, at_least_room_for,
USE_COMPUTED_MINIMUM_CAPACITY,
+ pretenure ? TENURED : NOT_TENURED);
table->Rehash(new_table, key);
return new_table;
@@ -15885,10 +15881,8 @@ Handle<Derived> Dictionary<Derived, Shape,
Key>::New(
int at_least_space_for,
PretenureFlag pretenure) {
DCHECK(0 <= at_least_space_for);
- Handle<Derived> dict = DerivedHashTable::New(isolate,
- at_least_space_for,
-
USE_DEFAULT_MINIMUM_CAPACITY,
- pretenure);
+ Handle<Derived> dict = DerivedHashTable::New(
+ isolate, at_least_space_for, USE_COMPUTED_MINIMUM_CAPACITY,
pretenure);
// Initialize the next enumeration index.
dict->SetNextEnumerationIndex(PropertyDetails::kInitialIndex);
Index: src/objects.h
diff --git a/src/objects.h b/src/objects.h
index
d6cbd4c44190eb4b3fc273b9728849816e2f6f90..8c0b6810e844c3c5063065657e415c74b723d6e5
100644
--- a/src/objects.h
+++ b/src/objects.h
@@ -3425,7 +3425,7 @@ class HashTable : public HashTableBase {
// Returns a new HashTable object.
MUST_USE_RESULT static Handle<Derived> New(
Isolate* isolate, int at_least_space_for,
- MinimumCapacity capacity_option = USE_DEFAULT_MINIMUM_CAPACITY,
+ MinimumCapacity capacity_option = USE_CUSTOM_MINIMUM_CAPACITY,
PretenureFlag pretenure = NOT_TENURED);
DECLARE_CAST(HashTable)
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.