Reviewers: mvstanton,

Description:
Use conservative hash table capacity growth during entire snapshotting.

We want to use the conservative growth strategy during
- isolate initialization
- bootstrapping a context

But not when
- not creating a snapshot
- running additional code for custom snapshot.

[email protected]
BUG=

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

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

Affected files (+9, -6 lines):
  M src/api.cc
  M src/isolate.h
  M src/objects.cc


Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index 125a31be06f94b802e9f61a465335ee641b8c189..c7126d742c4628b45ab064e3cbb3756c7ca87120 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -347,12 +347,14 @@ 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);
       Handle<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/isolate.h
diff --git a/src/isolate.h b/src/isolate.h
index ec9de6248fcdd32c52fe590e11d77d424c635103..2a37a3aa324dbf0c2dbf995d18eb748588f03d29 100644
--- a/src/isolate.h
+++ b/src/isolate.h
@@ -378,6 +378,7 @@ 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.cc
diff --git a/src/objects.cc b/src/objects.cc
index 7afce5a885b8e038a5a40c28437eb2036c08ecd9..d92f4bc0763be62d08127eabc84b2f3aeedcbd2a 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -14725,12 +14725,12 @@ Handle<Derived> HashTable<Derived, Shape, Key>::New(
     PretenureFlag pretenure) {
   DCHECK(0 <= at_least_space_for);
DCHECK(!capacity_option || base::bits::IsPowerOfTwo32(at_least_space_for));
-  int capacity =
-      (capacity_option == USE_CUSTOM_MINIMUM_CAPACITY)
-          ? at_least_space_for
- : isolate->serializer_enabled() && isolate->bootstrapper()->IsActive()
-                ? ComputeCapacityForSerialization(at_least_space_for)
-                : ComputeCapacity(at_least_space_for);
+
+  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);
   if (capacity > HashTable::kMaxCapacity) {
v8::internal::Heap::FatalProcessOutOfMemory("invalid table size", true);
   }


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