From b550792f0f9357f380d501288f368e85d43279b8 Mon Sep 17 00:00:00 2001 From: Hitoshi Yoshida Date: Tue, 23 Jan 2018 11:00:01 +0000 Subject: [PATCH] chrome: Unship snapshot_blob.bin from Win/Mac/Linux We are shipping snapshot_blob.bin and v8_context_snapshot.bin with Chrome for speed up of launching V8 environments. Beside it, v8_context_snapshot.bin contains all information in snapshot_blob.bin, and we no longer need snapshot_blob.bin if v8_context_snapshot.bin is available. This CL drops snapshot_blob.bin from Chrome for such platforms to reduce the size of shipping binaries and memory usages. Bug: 789964, 796127 Change-Id: I4c17f803212b845b2021936d7eb1eec913d76c68 Reviewed-on: https://chromium-review.googlesource.com/812587 Commit-Queue: Hitoshi Yoshida Reviewed-by: Ross McIlroy Reviewed-by: Lei Zhang Reviewed-by: Kentaro Hara Reviewed-by: Daniel Cheng Reviewed-by: Kinuko Yasuda Reviewed-by: Greg Thompson Reviewed-by: Michael Giuffrida Cr-Commit-Position: refs/heads/master@{#531204} --- chrome/BUILD.gn | 14 ++++++++------ chrome/installer/linux/common/installer.include | 8 ++++---- chrome/installer/mini_installer/BUILD.gn | 13 ++++++++----- chrome/installer/mini_installer/chrome.release | 1 - chrome/tools/build/linux/FILES.cfg | 10 ---------- chrome/tools/build/mac/FILES.cfg | 6 ------ chrome/tools/build/win/FILES.cfg | 11 ----------- content/app/content_main_runner.cc | 2 +- .../app/mojo/content_renderer_manifest.json | 4 ---- .../app/mojo/content_utility_manifest.json | 4 ---- content/shell/BUILD.gn | 16 +++++++++------- extensions/shell/BUILD.gn | 15 ++++++++------- .../installer/linux/common/installer.include | 10 ++++++++-- 13 files changed, 46 insertions(+), 68 deletions(-) diff --git a/chrome/BUILD.gn b/chrome/BUILD.gn index 960921acd7ebb0..148f27da14baaf 100644 --- a/chrome/BUILD.gn +++ b/chrome/BUILD.gn @@ -23,6 +23,7 @@ import("//ppapi/features/features.gni") import("//third_party/WebKit/public/public_features.gni") import("//third_party/widevine/cdm/widevine.gni") import("//tools/resources/generate_resource_whitelist.gni") +import("//tools/v8_context_snapshot/v8_context_snapshot.gni") import("//v8/gni/v8.gni") if (is_android) { @@ -852,7 +853,6 @@ if (is_win) { bundle_data("chrome_framework_resources") { sources = [ "$root_out_dir/app_mode_loader.app", - "$root_out_dir/v8_context_snapshot.bin", # This image is used to badge the lock icon in the # authentication dialogs, such as those used for installation @@ -872,7 +872,6 @@ if (is_win) { public_deps = [ ":packed_resources", "//chrome/app_shim:app_mode_loader", - "//tools/v8_context_snapshot", ] if (is_chrome_branded) { @@ -888,11 +887,14 @@ if (is_win) { } if (v8_use_external_startup_data) { - sources += [ - "$root_out_dir/natives_blob.bin", - "$root_out_dir/snapshot_blob.bin", - ] + sources += [ "$root_out_dir/natives_blob.bin" ] public_deps += [ "//v8" ] + if (use_v8_context_snapshot) { + sources += [ "$root_out_dir/v8_context_snapshot.bin" ] + public_deps += [ "//tools/v8_context_snapshot" ] + } else { + sources += [ "$root_out_dir/snapshot_blob.bin" ] + } } } diff --git a/chrome/installer/linux/common/installer.include b/chrome/installer/linux/common/installer.include index 73d801aac4ed8e..9bce61fe1df65f 100644 --- a/chrome/installer/linux/common/installer.include +++ b/chrome/installer/linux/common/installer.include @@ -159,12 +159,12 @@ stage_install_common() { # V8 snapshot files; Necessary when the GN v8_use_external_startup_data flag # is true. install -m 644 "${BUILDDIR}/natives_blob.bin" "${STAGEDIR}/${INSTALLDIR}/" - install -m 644 "${BUILDDIR}/snapshot_blob.bin" "${STAGEDIR}/${INSTALLDIR}/" - - # V8 context snapshot file; it will replace V8's snapshot_blob.bin - # TODO(peria): Remove snapshot_blob.bin when dependencies are resolved. + # Use v8_context_snapshot.bin instead of snapshot_blob.bin if it is available. + # TODO(crbug.com/764576): Unship snapshot_blob.bin on ChromeOS and drop this branch if [ -f "${BUILDDIR}/v8_context_snapshot.bin" ]; then install -m 644 "${BUILDDIR}/v8_context_snapshot.bin" "${STAGEDIR}/${INSTALLDIR}/" + else + install -m 644 "${BUILDDIR}/snapshot_blob.bin" "${STAGEDIR}/${INSTALLDIR}/" fi # sandbox diff --git a/chrome/installer/mini_installer/BUILD.gn b/chrome/installer/mini_installer/BUILD.gn index 73953730a70074..f606dfe04db8bb 100644 --- a/chrome/installer/mini_installer/BUILD.gn +++ b/chrome/installer/mini_installer/BUILD.gn @@ -9,6 +9,7 @@ import("//chrome/process_version_rc_template.gni") import("//chrome/test/mini_installer/mini_installer_test.gni") import("//components/nacl/features.gni") import("//third_party/icu/config.gni") +import("//tools/v8_context_snapshot/v8_context_snapshot.gni") import("//ui/base/ui_features.gni") import("//v8/gni/v8.gni") @@ -180,7 +181,6 @@ template("generate_mini_installer") { "//chrome/browser/extensions/default_extensions", "//chrome/installer/setup", "//third_party/icu:icudata", - "//tools/v8_context_snapshot", chrome_dll_target, ] @@ -212,11 +212,14 @@ template("generate_mini_installer") { } if (v8_use_external_startup_data) { - inputs += [ - "$root_out_dir/natives_blob.bin", - "$root_out_dir/snapshot_blob.bin", - ] + inputs += [ "$root_out_dir/natives_blob.bin" ] deps += [ "//v8" ] + if (use_v8_context_snapshot) { + inputs += [ "$root_out_dir/v8_context_snapshot.bin" ] + deps += [ "//tools/v8_context_snapshot" ] + } else { + inputs += [ "$root_out_dir/snapshot_blob.bin" ] + } } depfile = "$target_gen_dir/archive.d" diff --git a/chrome/installer/mini_installer/chrome.release b/chrome/installer/mini_installer/chrome.release index bb66e6bcdc2ccd..99e9577d827b85 100644 --- a/chrome/installer/mini_installer/chrome.release +++ b/chrome/installer/mini_installer/chrome.release @@ -34,7 +34,6 @@ nacl_irt_x86_32.nexe: %(VersionDir)s\ nacl_irt_x86_64.nexe: %(VersionDir)s\ natives_blob.bin: %(VersionDir)s\ resources.pak: %(VersionDir)s\ -snapshot_blob.bin: %(VersionDir)s\ syzyasan_rtl.dll: %(VersionDir)s\ v8_context_snapshot.bin: %(VersionDir)s\ # diff --git a/chrome/tools/build/linux/FILES.cfg b/chrome/tools/build/linux/FILES.cfg index 1918264820f6ab..3a5d618613841d 100644 --- a/chrome/tools/build/linux/FILES.cfg +++ b/chrome/tools/build/linux/FILES.cfg @@ -79,10 +79,6 @@ FILES = [ 'filename': 'session', 'buildtype': ['dev'], }, - { - 'filename': 'snapshot_blob.bin', - 'buildtype': ['dev', 'official'], - }, { 'filename': 'v8_context_snapshot.bin', 'buildtype': ['dev', 'official'], @@ -282,12 +278,6 @@ FILES = [ 'archive': 'content-shell.zip', 'optional': ['dev'], }, - { - 'filename': 'snapshot_blob.bin', - 'buildtype': ['dev'], - 'archive': 'content-shell.zip', - 'optional': ['dev'], - }, { 'filename': 'v8_context_snapshot.bin', 'buildtype': ['dev'], diff --git a/chrome/tools/build/mac/FILES.cfg b/chrome/tools/build/mac/FILES.cfg index a10d0b11d0e64a..5f925df345b112 100644 --- a/chrome/tools/build/mac/FILES.cfg +++ b/chrome/tools/build/mac/FILES.cfg @@ -109,12 +109,6 @@ FILES = [ 'archive': 'content-shell.zip', 'optional': ['dev'], }, - { - 'filename': 'snapshot_blob.bin', - 'buildtype': ['dev'], - 'archive': 'content-shell.zip', - 'optional': ['dev'], - }, { 'filename': 'v8_context_snapshot.bin', 'buildtype': ['dev'], diff --git a/chrome/tools/build/win/FILES.cfg b/chrome/tools/build/win/FILES.cfg index e82d791f1b6a01..f661f399adf6ca 100644 --- a/chrome/tools/build/win/FILES.cfg +++ b/chrome/tools/build/win/FILES.cfg @@ -112,11 +112,6 @@ FILES = [ 'buildtype': ['dev', 'official'], 'optional': ['dev', 'official'], }, - { - 'filename': 'snapshot_blob.bin', - 'buildtype': ['dev', 'official'], - 'optional': ['dev', 'official'], - }, { 'filename': 'v8_context_snapshot.bin', 'buildtype': ['dev', 'official'], @@ -819,12 +814,6 @@ FILES = [ 'archive': 'content-shell.zip', 'optional': ['dev'], }, - { - 'filename': 'snapshot_blob.bin', - 'buildtype': ['dev'], - 'archive': 'content-shell.zip', - 'optional': ['dev'], - }, { 'filename': 'v8_context_snapshot.bin', 'buildtype': ['dev'], diff --git a/content/app/content_main_runner.cc b/content/app/content_main_runner.cc index a36be8d5940f9b..6e5eaf928c73be 100644 --- a/content/app/content_main_runner.cc +++ b/content/app/content_main_runner.cc @@ -169,7 +169,6 @@ void InitializeFieldTrialAndFeatureList( } #if defined(V8_USE_EXTERNAL_STARTUP_DATA) - void LoadV8SnapshotFile() { #if defined(USE_V8_CONTEXT_SNAPSHOT) static constexpr gin::V8Initializer::V8SnapshotFileType kSnapshotType = @@ -196,6 +195,7 @@ void LoadV8SnapshotFile() { return; } #endif // OS_POSIX && !OS_MACOSX + #if !defined(CHROME_MULTIPLE_DLL_BROWSER) gin::V8Initializer::LoadV8Snapshot(kSnapshotType); #endif // !CHROME_MULTIPLE_DLL_BROWSER diff --git a/content/public/app/mojo/content_renderer_manifest.json b/content/public/app/mojo/content_renderer_manifest.json index 5efdd84bc08620..3ad58757c9ae97 100644 --- a/content/public/app/mojo/content_renderer_manifest.json +++ b/content/public/app/mojo/content_renderer_manifest.json @@ -92,10 +92,6 @@ "platform": "android" } ], - "v8_snapshot_data" : [{ - "path": "snapshot_blob.bin", - "platform": "linux" - }], "v8_snapshot_32_data" : [{ "path": "assets/snapshot_blob_32.bin", "platform": "android" diff --git a/content/public/app/mojo/content_utility_manifest.json b/content/public/app/mojo/content_utility_manifest.json index 4d07ae8e0f3011..acf8f28f66d997 100644 --- a/content/public/app/mojo/content_utility_manifest.json +++ b/content/public/app/mojo/content_utility_manifest.json @@ -43,10 +43,6 @@ "platform": "android" } ], - "v8_snapshot_data" : [{ - "path": "snapshot_blob.bin", - "platform": "linux" - }], "v8_snapshot_32_data" : [{ "path": "assets/snapshot_blob_32.bin", "platform": "android" diff --git a/content/shell/BUILD.gn b/content/shell/BUILD.gn index 4e0f2180255b86..76dd3cdfdff922 100644 --- a/content/shell/BUILD.gn +++ b/content/shell/BUILD.gn @@ -11,8 +11,9 @@ import("//media/media_options.gni") import("//mojo/public/tools/bindings/mojom.gni") import("//ppapi/features/features.gni") import("//services/service_manager/public/service_manifest.gni") -import("//tools/grit/repack.gni") import("//tools/grit/grit_rule.gni") +import("//tools/grit/repack.gni") +import("//tools/v8_context_snapshot/v8_context_snapshot.gni") if (is_android) { import("//build/config/android/config.gni") } else if (is_mac) { @@ -645,13 +646,11 @@ if (is_mac) { bundle_data("content_shell_framework_resources") { sources = [ "$root_out_dir/content_shell.pak", - "$root_out_dir/v8_context_snapshot.bin", "resources/missingImage.png", ] public_deps = [ ":pak", - "//tools/v8_context_snapshot:v8_context_snapshot", ] if (icu_use_data_file) { @@ -662,11 +661,14 @@ if (is_mac) { } if (v8_use_external_startup_data) { - sources += [ - "$root_out_dir/natives_blob.bin", - "$root_out_dir/snapshot_blob.bin", - ] + sources += [ "$root_out_dir/natives_blob.bin" ] public_deps += [ "//v8" ] + if (use_v8_context_snapshot) { + sources += [ "$root_out_dir/v8_context_snapshot.bin" ] + public_deps += [ "//tools/v8_context_snapshot" ] + } else { + sources += [ "$root_out_dir/snapshot_blob.bin" ] + } } outputs = [ diff --git a/extensions/shell/BUILD.gn b/extensions/shell/BUILD.gn index d74f2d1dee8b07..622d8f39ae2748 100644 --- a/extensions/shell/BUILD.gn +++ b/extensions/shell/BUILD.gn @@ -9,6 +9,7 @@ import("//components/nacl/features.gni") import("//extensions/features/features.gni") import("//testing/test.gni") import("//tools/grit/grit_rule.gni") +import("//tools/v8_context_snapshot/v8_context_snapshot.gni") if (is_mac) { import("//build/config/mac/rules.gni") import("//third_party/icu/config.gni") @@ -298,7 +299,6 @@ test("app_shell_unittests") { "$root_out_dir/extensions_shell_and_test.pak", #"$root_out_dir/natives_blob.bin", # move to gin - #"$root_out_dir/snapshot_blob.bin", ] deps = [ @@ -363,23 +363,24 @@ if (is_mac) { sources = [ "$root_gen_dir/extensions/shell/app_shell_resources.pak", "$root_out_dir/extensions_shell_and_test.pak", - "$root_out_dir/v8_context_snapshot.bin", ] public_deps = [ ":resources_grit", "//extensions:shell_and_test_pak", - "//tools/v8_context_snapshot:v8_context_snapshot", ] if (icu_use_data_file) { sources += [ "$root_out_dir/icudtl.dat" ] public_deps += [ "//third_party/icu:icudata" ] } if (v8_use_external_startup_data) { - sources += [ - "$root_out_dir/natives_blob.bin", - "$root_out_dir/snapshot_blob.bin", - ] + sources += [ "$root_out_dir/natives_blob.bin" ] public_deps += [ "//v8" ] + if (use_v8_context_snapshot) { + sources += [ "$root_out_dir/v8_context_snapshot.bin" ] + public_deps += [ "//tools/v8_context_snapshot" ] + } else { + sources += [ "$root_out_dir/snapshot_blob.bin" ] + } } outputs = [ "{{bundle_resources_dir}}/{{source_file_part}}", diff --git a/extensions/shell/installer/linux/common/installer.include b/extensions/shell/installer/linux/common/installer.include index 6c6e14dca89b44..d00349cb597ea6 100644 --- a/extensions/shell/installer/linux/common/installer.include +++ b/extensions/shell/installer/linux/common/installer.include @@ -122,11 +122,17 @@ stage_install_common() { # ICU data file; Necessary when the GN icu_use_data_file flag is true. install -m 644 "${BUILDDIR}/icudtl.dat" "${STAGEDIR}/${INSTALLDIR}/" - # V8 snapshot files; Necessary when the GN v8_use_external_startup_data flag + # V8 snapshot files; Necessary when the GN v8_use_external_startup_data flag # is true. if [ -f "${BUILDDIR}/natives_blob.bin" ]; then install -m 644 "${BUILDDIR}/natives_blob.bin" "${STAGEDIR}/${INSTALLDIR}/" - install -m 644 "${BUILDDIR}/snapshot_blob.bin" "${STAGEDIR}/${INSTALLDIR}/" + # Use v8_context_snapshot.bin instead of snapshot_blob.bin if it is available. + # TODO(crbug.com/764576): Unship snapshot_blob.bin on ChromeOS and drop this branch + if [ -f "${BUILDDIR}/v8_context_snapshot.bin" ]; then + install -m 644 "${BUILDDIR}/v8_context_snapshot.bin" "${STAGEDIR}/${INSTALLDIR}/" + else + install -m 644 "${BUILDDIR}/snapshot_blob.bin" "${STAGEDIR}/${INSTALLDIR}/" + fi fi # ANGLE