Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1393)

Unified Diff: src/snapshot/mksnapshot.cc

Issue 1805903002: [serializer] Add API to warm up startup snapshot with an additional script. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix comment Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/snapshot/deserializer.cc ('k') | src/snapshot/partial-serializer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/snapshot/mksnapshot.cc
diff --git a/src/snapshot/mksnapshot.cc b/src/snapshot/mksnapshot.cc
index 8cba00322d85c39202c84a0b8c7519d7c0bf1906..9d7b9e4dd62ebf02c9b0d78c6db0f09d1b8c5947 100644
--- a/src/snapshot/mksnapshot.cc
+++ b/src/snapshot/mksnapshot.cc
@@ -109,10 +109,10 @@ class SnapshotWriter {
FILE* startup_blob_file_;
};
-
-char* GetExtraCode(char* filename) {
+char* GetExtraCode(char* filename, const char* description) {
if (filename == NULL || strlen(filename) == 0) return NULL;
- ::printf("Embedding extra script: %s\n", filename);
+ if (strcmp(filename, "-") == 0) return NULL;
+ ::printf("Loading script for %s: %s\n", description, filename);
FILE* file = base::OS::FOpen(filename, "rb");
if (file == NULL) {
fprintf(stderr, "Failed to open '%s': errno %d\n", filename, errno);
@@ -144,7 +144,7 @@ int main(int argc, char** argv) {
// Print the usage if an error occurs when parsing the command line
// flags or if the help flag is set.
int result = i::FlagList::SetFlagsFromCommandLine(&argc, argv, true);
- if (result > 0 || (argc != 1 && argc != 2) || i::FLAG_help) {
+ if (result > 0 || (argc > 3) || i::FLAG_help) {
::printf("Usage: %s --startup_src=... --startup_blob=... [extras]\n",
argv[0]);
i::FlagList::PrintHelp();
@@ -161,11 +161,21 @@ int main(int argc, char** argv) {
SnapshotWriter writer;
if (i::FLAG_startup_src) writer.SetSnapshotFile(i::FLAG_startup_src);
if (i::FLAG_startup_blob) writer.SetStartupBlobFile(i::FLAG_startup_blob);
- char* extra_code = GetExtraCode(argc == 2 ? argv[1] : NULL);
- StartupData blob = v8::V8::CreateSnapshotDataBlob(extra_code);
+
+ char* embed_script = GetExtraCode(argc >= 2 ? argv[1] : NULL, "embedding");
+ StartupData blob = v8::V8::CreateSnapshotDataBlob(embed_script);
+ delete[] embed_script;
+
+ char* warmup_script = GetExtraCode(argc >= 3 ? argv[2] : NULL, "warm up");
+ if (warmup_script) {
+ StartupData cold = blob;
+ blob = v8::V8::WarmUpSnapshotDataBlob(cold, warmup_script);
+ delete[] cold.data;
+ delete[] warmup_script;
+ }
+
CHECK(blob.data);
writer.WriteSnapshot(blob);
- delete[] extra_code;
delete[] blob.data;
}
« no previous file with comments | « src/snapshot/deserializer.cc ('k') | src/snapshot/partial-serializer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698