Reviewers: jochen,

Description:
Serialzier: expand string table as last step before deserializing.

Not doing so could result in this scenario:
- We ensure that the string table is large enough. It is.
- We compile code stubs, which triggers a GC.
- The GC clears string table entries.
- This increases the number of deleted entries in the table.
- When the deserializer hooks up internalized strings into the
  table, we ensure that the table is large enough every time.
- Due to changed number of deleted entries, the heuristic
  decides to expand the string table.

BUG=chromium:502085
LOG=N

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

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

Affected files (+13, -9 lines):
  M src/snapshot/serialize.cc


Index: src/snapshot/serialize.cc
diff --git a/src/snapshot/serialize.cc b/src/snapshot/serialize.cc
index fe33c3e8b2d71e86aa6322ab5ff69700baa7b298..980e4997d6d8c1351d569aa29d86228486d848b0 100644
--- a/src/snapshot/serialize.cc
+++ b/src/snapshot/serialize.cc
@@ -564,11 +564,15 @@ void Deserializer::Deserialize(Isolate* isolate) {
   DCHECK_NULL(isolate_->thread_manager()->FirstThreadStateInUse());
   // No active handles.
   DCHECK(isolate_->handle_scope_implementer()->blocks()->is_empty());
-  isolate_->heap()->IterateSmiRoots(this);
-  isolate_->heap()->IterateStrongRoots(this, VISIT_ONLY_STRONG);
-  isolate_->heap()->RepairFreeListsAfterDeserialization();
-  isolate_->heap()->IterateWeakRoots(this, VISIT_ALL);
-  DeserializeDeferredObjects();
+
+  {
+    DisallowHeapAllocation no_gc;
+    isolate_->heap()->IterateSmiRoots(this);
+    isolate_->heap()->IterateStrongRoots(this, VISIT_ONLY_STRONG);
+    isolate_->heap()->RepairFreeListsAfterDeserialization();
+    isolate_->heap()->IterateWeakRoots(this, VISIT_ALL);
+    DeserializeDeferredObjects();
+  }

   isolate_->heap()->set_native_contexts_list(
       isolate_->heap()->undefined_value());
@@ -2431,10 +2435,6 @@ MaybeHandle<SharedFunctionInfo> CodeSerializer::Deserialize(
     return MaybeHandle<SharedFunctionInfo>();
   }

- // Eagerly expand string table to avoid allocations during deserialization.
-  StringTable::EnsureCapacityForDeserialization(isolate,
- scd->NumInternalizedStrings());
-
   // Prepare and register list of attached objects.
   Vector<const uint32_t> code_stub_keys = scd->CodeStubKeys();
   Vector<Handle<Object> > attached_objects = Vector<Handle<Object> >::New(
@@ -2445,6 +2445,10 @@ MaybeHandle<SharedFunctionInfo> CodeSerializer::Deserialize(
         CodeStub::GetCode(isolate, code_stub_keys[i]).ToHandleChecked();
   }

+ // Eagerly expand string table to avoid allocations during deserialization.
+  StringTable::EnsureCapacityForDeserialization(isolate,
+ scd->NumInternalizedStrings());
+
   Deserializer deserializer(scd.get());
   deserializer.SetAttachedObjects(attached_objects);



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