Reviewers: ulan,

Message:
Please take a look.

Description:
Remove serializer-specific hash table size heuristic.

The heuristic can cause weird behavior when bootstrapping.
The memory savings is not worth this hassle.

Please review this at https://codereview.chromium.org/1265983006/

Base URL: https://chromium.googlesource.com/v8/v8.git@master

Affected files (+3, -17 lines):
  M src/api.cc
  M src/bootstrapper.cc
  M src/isolate.h
  M src/objects.h
  M src/objects.cc
  M src/objects-inl.h


Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index 586fd8613a5a4b9dcaa5b47bfa4d56e65d804c7b..524b71dbf2ab6626b58705112301afa11073555c 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -367,14 +367,12 @@ StartupData V8::CreateSnapshotDataBlob(const char* custom_source) {
     base::ElapsedTimer timer;
     timer.Start();
     Isolate::Scope isolate_scope(isolate);
-    internal_isolate->set_creating_default_snapshot(true);
     internal_isolate->Init(NULL);
     Persistent<Context> context;
     i::Snapshot::Metadata metadata;
     {
       HandleScope handle_scope(isolate);
       Local<Context> new_context = Context::New(isolate);
-      internal_isolate->set_creating_default_snapshot(false);
       context.Reset(isolate, new_context);
       if (custom_source != NULL) {
         metadata.set_embeds_script(true);
Index: src/bootstrapper.cc
diff --git a/src/bootstrapper.cc b/src/bootstrapper.cc
index 838510000832229b37d7b8c1702b03501dcbf0b2..408055a3cbf6915386942897bf002378029b4904 100644
--- a/src/bootstrapper.cc
+++ b/src/bootstrapper.cc
@@ -2411,7 +2411,8 @@ bool Genesis::InstallNatives(ContextType context_type) {
   InstallNativeFunctions();

   auto function_cache =
- ObjectHashTable::New(isolate(), ApiNatives::kInitialFunctionCacheSize); + ObjectHashTable::New(isolate(), ApiNatives::kInitialFunctionCacheSize,
+                           USE_CUSTOM_MINIMUM_CAPACITY);
   native_context()->set_function_cache(*function_cache);

// Store the map for the string prototype after the natives has been compiled
Index: src/isolate.h
diff --git a/src/isolate.h b/src/isolate.h
index a11f75ab290a1ce82439fa89c5508f3167e567bb..fe1f51b5c64f33969b52a2b579a261c7329d8e44 100644
--- a/src/isolate.h
+++ b/src/isolate.h
@@ -385,7 +385,6 @@ typedef List<HeapObject*> DebugObjectCache;
V(uint32_t, per_isolate_assert_data, 0xFFFFFFFFu) \ V(PromiseRejectCallback, promise_reject_callback, NULL) \ V(const v8::StartupData*, snapshot_blob, NULL) \ - V(bool, creating_default_snapshot, false) \
   ISOLATE_INIT_SIMULATOR_LIST(V)

 #define THREAD_LOCAL_TOP_ACCESSOR(type, name)                        \
Index: src/objects-inl.h
diff --git a/src/objects-inl.h b/src/objects-inl.h
index 4929c0d2dfd56a70900d070e8d2b2e87f52120c2..4fce54a90a442159228d900b6f7488281dcb9cdf 100644
--- a/src/objects-inl.h
+++ b/src/objects-inl.h
@@ -2840,13 +2840,6 @@ int HashTableBase::ComputeCapacity(int at_least_space_for) {
 }


-int HashTableBase::ComputeCapacityForSerialization(int at_least_space_for) {
-  const int kMinCapacity = 1;
-  int capacity = base::bits::RoundUpToPowerOfTwo32(at_least_space_for);
-  return Max(capacity, kMinCapacity);
-}
-
-
 template <typename Derived, typename Shape, typename Key>
 int HashTable<Derived, Shape, Key>::FindEntry(Key key) {
   return FindEntry(GetIsolate(), key);
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index 8bb95c518c79327fe1548fcdf8cf017a9004cd16..eae44549aa061d1b855e84b6222e9f7de02b49bf 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -13346,9 +13346,7 @@ Handle<Derived> HashTable<Derived, Shape, Key>::New(

   int capacity = (capacity_option == USE_CUSTOM_MINIMUM_CAPACITY)
                      ? at_least_space_for
-                     : isolate->creating_default_snapshot()
- ? ComputeCapacityForSerialization(at_least_space_for)
-                           : ComputeCapacity(at_least_space_for);
+                     : ComputeCapacity(at_least_space_for);
   if (capacity > HashTable::kMaxCapacity) {
v8::internal::Heap::FatalProcessOutOfMemory("invalid table size", true);
   }
Index: src/objects.h
diff --git a/src/objects.h b/src/objects.h
index d84690fbd48c6b3418663960916d7987a84f6dfc..6f86e94e4cc0fdb9fc57f072da1e1abe574ddd68 100644
--- a/src/objects.h
+++ b/src/objects.h
@@ -2907,9 +2907,6 @@ class HashTableBase : public FixedArray {
   // number of elements. May be more than HashTable::kMaxCapacity.
   static inline int ComputeCapacity(int at_least_space_for);

-  // Use a different heuristic to compute capacity when serializing.
- static inline int ComputeCapacityForSerialization(int at_least_space_for);
-
   // Tells whether k is a real key.  The hole and undefined are not allowed
   // as keys and can be used to indicate missing or deleted elements.
   bool IsKey(Object* k) {


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

Reply via email to