Reviewers: Toon Verwaest,

Description:
Do not include cached code in the start-up snapshot.

The non-monomorphic cache and the code stub cache contain
stubs that are not really useful immediate at start-up.
For example we have a lot of RecordWriteStubs for different
register combinations.

This cuts the start-up snapshot size by another 1/3.

[email protected]

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

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

Affected files (+17, -7 lines):
  M src/api.cc


Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index 0d0bf3f75a6a8d2e01e1d57ac006ff2b7b5cb1c1..4954081067a830200d86a03b54726fd98a1aae04 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -359,12 +359,12 @@ bool RunExtraCode(Isolate* isolate, const char* utf8_source) {


 StartupData V8::CreateSnapshotDataBlob(const char* custom_source) {
-  i::Isolate* internal_isolate = new i::Isolate(true);
-  Isolate* isolate = reinterpret_cast<Isolate*>(internal_isolate);
+  i::Isolate* i_isolate = new i::Isolate(true);
+  Isolate* isolate = reinterpret_cast<Isolate*>(i_isolate);
   StartupData result = {NULL, 0};
   {
     Isolate::Scope isolate_scope(isolate);
-    internal_isolate->Init(NULL);
+    i_isolate->Init(NULL);
     Persistent<Context> context;
     i::Snapshot::Metadata metadata;
     {
@@ -382,21 +382,31 @@ StartupData V8::CreateSnapshotDataBlob(const char* custom_source) {
       {
         HandleScope scope(isolate);
         for (int i = 0; i < i::Natives::GetBuiltinsCount(); i++) {
-          internal_isolate->bootstrapper()->NativesSourceLookup(i);
+          i_isolate->bootstrapper()->NativesSourceLookup(i);
         }
       }
// If we don't do this then we end up with a stray root pointing at the
       // context even after we have disposed of the context.
-      internal_isolate->heap()->CollectAllAvailableGarbage("mksnapshot");
+      i_isolate->heap()->CollectAllAvailableGarbage("mksnapshot");
+
+      {
+        HandleScope scope(isolate);
+        // Clear code caches.
+        i_isolate->heap()->public_set_code_stubs(
+            *i::UnseededNumberDictionary::New(i_isolate, 128, i::TENURED));
+        i_isolate->heap()->public_set_non_monomorphic_cache(
+            *i::UnseededNumberDictionary::New(i_isolate, 64, i::TENURED));
+      }
+
       i::Object* raw_context = *v8::Utils::OpenPersistent(context);
       context.Reset();

       i::SnapshotByteSink snapshot_sink;
-      i::StartupSerializer ser(internal_isolate, &snapshot_sink);
+      i::StartupSerializer ser(i_isolate, &snapshot_sink);
       ser.SerializeStrongReferences();

       i::SnapshotByteSink context_sink;
- i::PartialSerializer context_ser(internal_isolate, &ser, &context_sink);
+      i::PartialSerializer context_ser(i_isolate, &ser, &context_sink);
       context_ser.Serialize(&raw_context);
       ser.SerializeWeakReferences();



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