summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--android_webview/android_webview_tests.gypi14
-rw-r--r--android_webview/test/shell/src/org/chromium/android_webview/shell/AwShellApplication.java4
-rw-r--r--base/android/java/src/org/chromium/base/ResourceExtractor.java43
-rw-r--r--build/android/pylib/gtest/setup.py1
-rw-r--r--build/common.gypi12
-rw-r--r--build/isolate.gypi1
-rw-r--r--chrome/android/shell/java/src/org/chromium/chrome/shell/ChromeShellApplication.java6
-rw-r--r--chrome/browser/chrome_content_browser_client.cc20
-rw-r--r--chrome/browser/resources/chromeos/chromevox/chromevox_tests.gypi20
-rw-r--r--chrome/chrome.isolate1
-rw-r--r--chrome/chrome_android_paks.gypi10
-rw-r--r--chrome/chrome_tests.gypi20
-rw-r--r--chrome/chrome_tests_unit.gypi17
-rw-r--r--chrome/installer/mini_installer.gyp6
-rw-r--r--chrome/interactive_ui_tests.isolate1
-rw-r--r--chrome/js_unittest_rules.gypi10
-rw-r--r--chrome/sync_integration_tests.isolate1
-rw-r--r--chrome/unit_tests.isolate1
-rw-r--r--components/components_unittests.isolate1
-rw-r--r--components/nacl_loader_unittests.isolate1
-rw-r--r--content/app/DEPS2
-rw-r--r--content/app/content_main_runner.cc23
-rw-r--r--content/content.gyp17
-rw-r--r--content/content_browsertests.isolate1
-rw-r--r--content/content_gl_tests.isolate1
-rw-r--r--content/content_shell.gypi7
-rw-r--r--content/content_tests.gypi33
-rw-r--r--content/content_unittests.isolate1
-rw-r--r--content/public/common/content_descriptors.h6
-rw-r--r--content/public/test/DEPS1
-rw-r--r--content/public/test/content_test_suite_base.cc8
-rw-r--r--content/shell/android/browsertests_apk/src/org/chromium/content_browsertests_apk/ContentBrowserTestsApplication.java4
-rw-r--r--content/shell/android/linker_test_apk/src/org/chromium/chromium_linker_test_apk/ChromiumLinkerTestApplication.java8
-rw-r--r--content/shell/android/shell_apk/src/org/chromium/content_shell_apk/ContentShellApplication.java8
-rw-r--r--content/test/DEPS2
-rw-r--r--content/test/content_test_launcher.cc8
-rw-r--r--content/test/test_blink_web_unit_test_support.cc8
-rw-r--r--gin/isolate_holder.cc80
-rw-r--r--gin/public/isolate_holder.h11
-rw-r--r--gin/shell/gin_main.cc3
-rw-r--r--gin/shell_runner_unittest.cc8
-rw-r--r--gin/test/file_runner.cc8
-rw-r--r--gin/test/v8_test.cc7
-rw-r--r--gin/v8.isolate15
-rw-r--r--net/net.gyp22
-rw-r--r--net/net.isolate1
-rw-r--r--net/net_unittests.isolate1
-rw-r--r--net/test/run_all_unittests.cc8
-rw-r--r--testing/android/java/src/org/chromium/native_test/ChromeNativeTestActivity.java2
-rw-r--r--third_party/android_webview_glue/android_webview_glue.gypi6
-rw-r--r--third_party/android_webview_glue/android_webview_glue_common.gypi6
-rwxr-xr-xtools/gypv8sh.py8
52 files changed, 495 insertions, 19 deletions
diff --git a/android_webview/android_webview_tests.gypi b/android_webview/android_webview_tests.gypi
index d775cc9..9ef2289 100644
--- a/android_webview/android_webview_tests.gypi
+++ b/android_webview/android_webview_tests.gypi
@@ -35,6 +35,12 @@
'<(PRODUCT_DIR)/icudtl.dat',
],
}],
+ ['v8_use_external_startup_data==1', {
+ 'additional_input_paths': [
+ '<(PRODUCT_DIR)/natives_blob.bin',
+ '<(PRODUCT_DIR)/snapshot_blob.bin',
+ ],
+ }],
],
},
'copies': [
@@ -55,7 +61,13 @@
'files': [
'<(PRODUCT_DIR)/icudtl.dat',
],
- }],
+ }],
+ ['v8_use_external_startup_data==1', {
+ 'files': [
+ '<(PRODUCT_DIR)/natives_blob.bin',
+ '<(PRODUCT_DIR)/snapshot_blob.bin',
+ ],
+ }],
],
},
],
diff --git a/android_webview/test/shell/src/org/chromium/android_webview/shell/AwShellApplication.java b/android_webview/test/shell/src/org/chromium/android_webview/shell/AwShellApplication.java
index 46276ab..62158ff 100644
--- a/android_webview/test/shell/src/org/chromium/android_webview/shell/AwShellApplication.java
+++ b/android_webview/test/shell/src/org/chromium/android_webview/shell/AwShellApplication.java
@@ -21,7 +21,9 @@ public class AwShellApplication extends Application {
private static final String TAG = "AwShellApplication";
/** The minimum set of .pak files the test runner needs. */
- private static final String[] MANDATORY_PAKS = { "icudtl.dat" };
+ private static final String[] MANDATORY_PAKS = { "icudtl.dat",
+ "natives_blob.bin",
+ "snapshot_blob.bin" };
@Override
public void onCreate() {
diff --git a/base/android/java/src/org/chromium/base/ResourceExtractor.java b/base/android/java/src/org/chromium/base/ResourceExtractor.java
index 4cf155c..37fea6c 100644
--- a/base/android/java/src/org/chromium/base/ResourceExtractor.java
+++ b/base/android/java/src/org/chromium/base/ResourceExtractor.java
@@ -36,6 +36,8 @@ public class ResourceExtractor {
private static final String LAST_LANGUAGE = "Last language";
private static final String PAK_FILENAMES = "Pak filenames";
private static final String ICU_DATA_FILENAME = "icudtl.dat";
+ private static final String V8_NATIVES_DATA_FILENAME = "natives_blob.bin";
+ private static final String V8_SNAPSHOT_DATA_FILENAME = "snapshot_blob.bin";
private static String[] sMandatoryPaks = null;
@@ -111,8 +113,11 @@ public class ResourceExtractor {
if (!paksToInstall.matcher(file).matches()) {
continue;
}
- boolean isICUData = file.equals(ICU_DATA_FILENAME);
- File output = new File(isICUData ? getAppDataDir() : outputDir, file);
+ boolean isAppDataFile = file.equals(ICU_DATA_FILENAME)
+ || file.equals(V8_NATIVES_DATA_FILENAME)
+ || file.equals(V8_SNAPSHOT_DATA_FILENAME);
+ File output = new File(isAppDataFile
+ ? getAppDataDir() : outputDir, file);
if (output.exists()) {
continue;
}
@@ -138,10 +143,11 @@ public class ResourceExtractor {
throw new IOException(file + " extracted with 0 length!");
}
- if (!isICUData) {
+ if (!isAppDataFile) {
filenames.add(file);
} else {
- // icudata needs to be accessed by a renderer process.
+ // icu and V8 data need to be accessed by a renderer
+ // process.
output.setReadable(true, false);
}
} finally {
@@ -274,18 +280,21 @@ public class ResourceExtractor {
* running the tests.
*/
@VisibleForTesting
- public void setExtractAllPaksForTesting() {
- List<String> pakFileAssets = new ArrayList<String>();
+ public void setExtractAllPaksAndV8SnapshotForTesting() {
+ List<String> pakAndSnapshotFileAssets = new ArrayList<String>();
AssetManager manager = mContext.getResources().getAssets();
try {
String[] files = manager.list("");
for (String file : files) {
- if (file.endsWith(".pak")) pakFileAssets.add(file);
+ if (file.endsWith(".pak")) pakAndSnapshotFileAssets.add(file);
}
} catch (IOException e) {
Log.w(LOGTAG, "Exception while accessing assets: " + e.getMessage(), e);
}
- setMandatoryPaksToExtract(pakFileAssets.toArray(new String[pakFileAssets.size()]));
+ pakAndSnapshotFileAssets.add("natives_blob.bin");
+ pakAndSnapshotFileAssets.add("snapshot_blob.bin");
+ setMandatoryPaksToExtract(pakAndSnapshotFileAssets.toArray(
+ new String[pakAndSnapshotFileAssets.size()]));
}
private ResourceExtractor(Context context) {
@@ -340,15 +349,27 @@ public class ResourceExtractor {
/**
* Pak files (UI strings and other resources) should be updated along with
* Chrome. A version mismatch can lead to a rather broken user experience.
- * The ICU data (icudtl.dat) is less version-sensitive, but still can
- * lead to malfunction/UX misbehavior. So, we regard failing to update them
- * as an error.
+ * Failing to update the V8 snapshot files will lead to a version mismatch
+ * between V8 and the loaded snapshot which will cause V8 to crash, so this
+ * is treated as an error. The ICU data (icudtl.dat) is less
+ * version-sensitive, but still can lead to malfunction/UX misbehavior. So,
+ * we regard failing to update them as an error.
*/
private void deleteFiles() {
File icudata = new File(getAppDataDir(), ICU_DATA_FILENAME);
if (icudata.exists() && !icudata.delete()) {
Log.e(LOGTAG, "Unable to remove the icudata " + icudata.getName());
}
+ File v8_natives = new File(getAppDataDir(), V8_NATIVES_DATA_FILENAME);
+ if (v8_natives.exists() && !v8_natives.delete()) {
+ Log.e(LOGTAG,
+ "Unable to remove the v8 data " + v8_natives.getName());
+ }
+ File v8_snapshot = new File(getAppDataDir(), V8_SNAPSHOT_DATA_FILENAME);
+ if (v8_snapshot.exists() && !v8_snapshot.delete()) {
+ Log.e(LOGTAG,
+ "Unable to remove the v8 data " + v8_snapshot.getName());
+ }
File dir = getOutputDir();
if (dir.exists()) {
File[] files = dir.listFiles();
diff --git a/build/android/pylib/gtest/setup.py b/build/android/pylib/gtest/setup.py
index c3af91f..5581fbc 100644
--- a/build/android/pylib/gtest/setup.py
+++ b/build/android/pylib/gtest/setup.py
@@ -122,6 +122,7 @@ def _GenerateDepsDirUsingIsolate(suite_name, isolate_file_path=None):
'--config-variable', 'fastbuild', '0',
'--config-variable', 'icu_use_data_file_flag', '1',
'--config-variable', 'libpeer_target_type', 'static_library',
+ '--config-variable', 'v8_use_external_startup_data', '0',
'--config-variable', 'lsan', '0',
# TODO(maruel): This may not be always true.
'--config-variable', 'target_arch', 'arm',
diff --git a/build/common.gypi b/build/common.gypi
index dcba6de..ffcf4aa 100644
--- a/build/common.gypi
+++ b/build/common.gypi
@@ -1004,6 +1004,14 @@
}, {
'optimize_jni_generation%': 0,
}],
+
+ # TODO(baixo): Enable v8_use_external_startup_data
+ # http://crbug.com/421063
+ ['android_webview_build==0 and android_webview_telemetry_build==0 and chromecast==0', {
+ 'v8_use_external_startup_data': 0,
+ }, {
+ 'v8_use_external_startup_data': 0,
+ }],
],
# Set this to 1 to enable use of concatenated impulse responses
@@ -1205,6 +1213,7 @@
'video_hole%': '<(video_hole)',
'enable_load_completion_hacks%': '<(enable_load_completion_hacks)',
'support_pre_M6_history_database%': '<(support_pre_M6_history_database)',
+ 'v8_use_external_startup_data': '<(v8_use_external_startup_data)',
# Whether or not we are building the Athena shell.
'use_athena%': '0',
@@ -2925,6 +2934,9 @@
['enable_load_completion_hacks==1', {
'defines': ['ENABLE_LOAD_COMPLETION_HACKS=1'],
}],
+ ['v8_use_external_startup_data==1', {
+ 'defines': ['V8_USE_EXTERNAL_STARTUP_DATA'],
+ }],
], # conditions for 'target_defaults'
'target_conditions': [
['<(use_openssl)==1', {
diff --git a/build/isolate.gypi b/build/isolate.gypi
index 17bf3c7..467bdaa 100644
--- a/build/isolate.gypi
+++ b/build/isolate.gypi
@@ -85,6 +85,7 @@
'--config-variable',
'internal_gles2_conform_tests=<(internal_gles2_conform_tests)',
'--config-variable', 'icu_use_data_file_flag=<(icu_use_data_file_flag)',
+ '--config-variable', 'v8_use_external_startup_data=<(v8_use_external_startup_data)',
'--config-variable', 'lsan=<(lsan)',
'--config-variable', 'libpeer_target_type=<(libpeer_target_type)',
'--config-variable', 'use_openssl=<(use_openssl)',
diff --git a/chrome/android/shell/java/src/org/chromium/chrome/shell/ChromeShellApplication.java b/chrome/android/shell/java/src/org/chromium/chrome/shell/ChromeShellApplication.java
index 17ae832..9df9aea 100644
--- a/chrome/android/shell/java/src/org/chromium/chrome/shell/ChromeShellApplication.java
+++ b/chrome/android/shell/java/src/org/chromium/chrome/shell/ChromeShellApplication.java
@@ -31,12 +31,18 @@ public class ChromeShellApplication extends ChromiumApplication {
* for its operation. We used to link the data statically to our binary,
* but don't do that any more and need to install along with pak files.
* See src/third_party/icu/README.chromium.
+ *
+ * V8's initial snapshot used to be statically linked to the binary, but
+ * now it's loaded from external files. Therefore we need to install such
+ * snapshots (natives_blob.bin and snapshot.bin) along with pak files.
*/
private static final String[] CHROME_MANDATORY_PAKS = {
"en-US.pak",
"resources.pak",
"chrome_100_percent.pak",
"icudtl.dat",
+ "natives_blob.bin",
+ "snapshot_blob.bin"
};
private static final String COMMAND_LINE_FILE = "/data/local/tmp/chrome-shell-command-line";
diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc
index 446e560a..f7fd810 100644
--- a/chrome/browser/chrome_content_browser_client.cc
+++ b/chrome/browser/chrome_content_browser_client.cc
@@ -2503,6 +2503,26 @@ void ChromeContentBrowserClient::GetAdditionalMappedFilesForChildProcess(
mappings->Transfer(kAndroidICUDataDescriptor,
base::ScopedFD(icudata_file.TakePlatformFile()));
+#ifdef V8_USE_EXTERNAL_STARTUP_DATA
+ base::FilePath v8_data_path;
+ PathService::Get(base::DIR_ANDROID_APP_DATA, &v8_data_path);
+ DCHECK(!v8_data_path.empty());
+
+ int file_flags = base::File::FLAG_OPEN | base::File::FLAG_READ;
+ base::FilePath v8_natives_data_path =
+ v8_data_path.AppendASCII("natives_blob.bin");
+ base::FilePath v8_snapshot_data_path =
+ v8_data_path.AppendASCII("snapshot_blob.bin");
+ base::File v8_natives_data_file(v8_natives_data_path, file_flags);
+ base::File v8_snapshot_data_file(v8_snapshot_data_path, file_flags);
+ DCHECK(v8_natives_data_file.IsValid());
+ DCHECK(v8_snapshot_data_file.IsValid());
+ mappings->Transfer(kV8NativesDataDescriptor,
+ base::ScopedFD(v8_natives_data_file.TakePlatformFile()));
+ mappings->Transfer(kV8SnapshotDataDescriptor,
+ base::ScopedFD(v8_snapshot_data_file.TakePlatformFile()));
+#endif // V8_USE_EXTERNAL_STARTUP_DATA
+
#else
int crash_signal_fd = GetCrashSignalFD(command_line);
if (crash_signal_fd >= 0) {
diff --git a/chrome/browser/resources/chromeos/chromevox/chromevox_tests.gypi b/chrome/browser/resources/chromeos/chromevox/chromevox_tests.gypi
index c4a1e9a..e9c9f61 100644
--- a/chrome/browser/resources/chromeos/chromevox/chromevox_tests.gypi
+++ b/chrome/browser/resources/chromeos/chromevox/chromevox_tests.gypi
@@ -45,6 +45,15 @@
'rule_name': 'js2webui',
'extension': 'unitjs',
'msvs_external_rule': 1,
+ 'variables': {
+ 'conditions': [
+ ['v8_use_external_startup_data==1', {
+ 'external_v8': 'y',
+ }, {
+ 'external_v8': 'n',
+ }],
+ ],
+ },
'inputs': [
'<(gypv8sh)',
'<(PRODUCT_DIR)/d8<(EXECUTABLE_SUFFIX)',
@@ -65,6 +74,7 @@
'<(gypv8sh)',
'<(PRODUCT_DIR)/d8<(EXECUTABLE_SUFFIX)',
'--deps_js', '<(chromevox_test_deps_js_file)',
+ '--external', '<(external_v8)',
'<(mock_js)',
'<(test_api_js)',
'<(js2gtest)',
@@ -80,6 +90,15 @@
'rule_name': 'js2extension',
'extension': 'extjs',
'msvs_external_rule': 1,
+ 'variables': {
+ 'conditions': [
+ ['v8_use_external_startup_data==1', {
+ 'external_v8': 'y',
+ }, {
+ 'external_v8': 'n',
+ }],
+ ],
+ },
'inputs': [
'<(gypv8sh)',
'<(PRODUCT_DIR)/d8<(EXECUTABLE_SUFFIX)',
@@ -98,6 +117,7 @@
'python',
'<(gypv8sh)',
'<(PRODUCT_DIR)/d8<(EXECUTABLE_SUFFIX)',
+ '--external', '<(external_v8)',
'<(mock_js)',
'<(test_api_js)',
'<(js2gtest)',
diff --git a/chrome/chrome.isolate b/chrome/chrome.isolate
index 5457f64..54e18dc 100644
--- a/chrome/chrome.isolate
+++ b/chrome/chrome.isolate
@@ -94,5 +94,6 @@
],
'includes': [
'angle.isolate',
+ '../gin/v8.isolate',
],
}
diff --git a/chrome/chrome_android_paks.gypi b/chrome/chrome_android_paks.gypi
index 90f0238..574d5cc 100644
--- a/chrome/chrome_android_paks.gypi
+++ b/chrome/chrome_android_paks.gypi
@@ -109,6 +109,16 @@
'<(chrome_android_pak_output_folder)/icudtl.dat',
],
}],
+ ['v8_use_external_startup_data==1', {
+ 'chrome_android_pak_input_resources': [
+ '<(PRODUCT_DIR)/natives_blob.bin',
+ '<(PRODUCT_DIR)/snapshot_blob.bin',
+ ],
+ 'chrome_android_pak_output_resources': [
+ '<(chrome_android_pak_output_folder)/natives_blob.bin',
+ '<(chrome_android_pak_output_folder)/snapshot_blob.bin',
+ ],
+ }],
],
},
}
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi
index 7822385..d89d00b 100644
--- a/chrome/chrome_tests.gypi
+++ b/chrome/chrome_tests.gypi
@@ -1880,6 +1880,15 @@
'rule_name': 'js2webui',
'extension': 'js',
'msvs_external_rule': 1,
+ 'variables': {
+ 'conditions': [
+ ['v8_use_external_startup_data==1', {
+ 'external_v8': 'y',
+ }, {
+ 'external_v8': 'n',
+ }],
+ ],
+ },
'inputs': [
'<(gypv8sh)',
'<(PRODUCT_DIR)/d8<(EXECUTABLE_SUFFIX)',
@@ -1895,6 +1904,7 @@
'action': [
'python',
'<@(_inputs)',
+ '--external', '<(external_v8)',
'webui',
'<(RULE_INPUT_PATH)',
'chrome/<(RULE_INPUT_DIRNAME)/<(RULE_INPUT_ROOT).js',
@@ -2450,6 +2460,15 @@
'rule_name': 'js2webui',
'extension': 'js',
'msvs_external_rule': 1,
+ 'variables': {
+ 'conditions': [
+ ['v8_use_external_startup_data==1', {
+ 'external_v8': 'y',
+ }, {
+ 'external_v8': 'n',
+ }],
+ ],
+ },
'inputs': [
'<(gypv8sh)',
'<(PRODUCT_DIR)/d8<(EXECUTABLE_SUFFIX)',
@@ -2466,6 +2485,7 @@
'python',
'<@(_inputs)',
'webui',
+ '--external', '<(external_v8)',
'<(RULE_INPUT_PATH)',
'chrome/<(RULE_INPUT_DIRNAME)/<(RULE_INPUT_ROOT).js',
'<@(_outputs)',
diff --git a/chrome/chrome_tests_unit.gypi b/chrome/chrome_tests_unit.gypi
index c98c284..8457225 100644
--- a/chrome/chrome_tests_unit.gypi
+++ b/chrome/chrome_tests_unit.gypi
@@ -2851,6 +2851,23 @@
'variables': {
'test_suite_name': 'unit_tests',
'android_manifest_path': 'test/android/unit_tests_apk/AndroidManifest.xml',
+ 'conditions': [
+ ['v8_use_external_startup_data==1', {
+ 'additional_input_paths': [
+ '<(PRODUCT_DIR)/natives_blob.bin',
+ '<(PRODUCT_DIR)/snapshot_blob.bin',
+ ],
+ 'copies': [
+ {
+ 'destination': '<(PRODUCT_DIR)/unit_tests_apk/assets',
+ 'files': [
+ '<(PRODUCT_DIR)/natives_blob.bin',
+ '<(PRODUCT_DIR)/snapshot_blob.bin',
+ ],
+ },
+ ],
+ }],
+ ],
},
'includes': [ '../build/apk_test.gypi' ],
},
diff --git a/chrome/installer/mini_installer.gyp b/chrome/installer/mini_installer.gyp
index c2bb835..e6b0ca7 100644
--- a/chrome/installer/mini_installer.gyp
+++ b/chrome/installer/mini_installer.gyp
@@ -224,6 +224,12 @@
'<(PRODUCT_DIR)/icudtl.dat',
],
}],
+ ['v8_use_external_startup_data == 1', {
+ 'inputs': [
+ '<(PRODUCT_DIR)/natives_blob.bin',
+ '<(PRODUCT_DIR)/snapshot_blob.bin',
+ ],
+ }],
],
'inputs': [
'<(create_installer_archive_py_path)',
diff --git a/chrome/interactive_ui_tests.isolate b/chrome/interactive_ui_tests.isolate
index df3893d..066c007 100644
--- a/chrome/interactive_ui_tests.isolate
+++ b/chrome/interactive_ui_tests.isolate
@@ -122,5 +122,6 @@
],
'includes': [
'../base/base.isolate',
+ '../gin/v8.isolate',
],
}
diff --git a/chrome/js_unittest_rules.gypi b/chrome/js_unittest_rules.gypi
index 27901f1c..b3dff9c 100644
--- a/chrome/js_unittest_rules.gypi
+++ b/chrome/js_unittest_rules.gypi
@@ -54,6 +54,15 @@
'rule_name': 'js2unit',
'extension': 'gtestjs',
'msvs_external_rule': 1,
+ 'variables': {
+ 'conditions': [
+ ['v8_use_external_startup_data==1', {
+ 'external_v8': 'y',
+ }, {
+ 'external_v8': 'n',
+ }],
+ ],
+ },
'inputs': [
'<(gypv8sh)',
'<(PRODUCT_DIR)/d8<(EXECUTABLE_SUFFIX)',
@@ -69,6 +78,7 @@
'action': [
'python',
'<@(_inputs)',
+ '--external', '<(external_v8)',
'unit',
'<(RULE_INPUT_PATH)',
'chrome/<(RULE_INPUT_DIRNAME)/<(RULE_INPUT_ROOT).<(_extension)',
diff --git a/chrome/sync_integration_tests.isolate b/chrome/sync_integration_tests.isolate
index 4c01825..3c5e0e1 100644
--- a/chrome/sync_integration_tests.isolate
+++ b/chrome/sync_integration_tests.isolate
@@ -98,5 +98,6 @@
],
'includes': [
'../base/base.isolate',
+ '../gin/v8.isolate',
],
}
diff --git a/chrome/unit_tests.isolate b/chrome/unit_tests.isolate
index 2a5814f..a78618a 100644
--- a/chrome/unit_tests.isolate
+++ b/chrome/unit_tests.isolate
@@ -139,5 +139,6 @@
],
'includes': [
'../base/base.isolate',
+ '../gin/v8.isolate',
],
}
diff --git a/components/components_unittests.isolate b/components/components_unittests.isolate
index 4d83010..a284dc1 100644
--- a/components/components_unittests.isolate
+++ b/components/components_unittests.isolate
@@ -17,5 +17,6 @@
],
'includes': [
'../third_party/icu/icu.isolate',
+ '../gin/v8.isolate',
],
}
diff --git a/components/nacl_loader_unittests.isolate b/components/nacl_loader_unittests.isolate
index bdb01e0..51bb35c 100644
--- a/components/nacl_loader_unittests.isolate
+++ b/components/nacl_loader_unittests.isolate
@@ -17,5 +17,6 @@
],
'includes': [
'../sandbox/sandbox_linux_unittests.isolate',
+ '../gin/v8.isolate',
],
}
diff --git a/content/app/DEPS b/content/app/DEPS
index 321c9ff..1fbfcab 100644
--- a/content/app/DEPS
+++ b/content/app/DEPS
@@ -1,4 +1,6 @@
include_rules = [
"+content",
+ # For loading V8's initial snapshot from external files.
+ "+gin/public/isolate_holder.h",
"+media/base", # For initializing media library.
]
diff --git a/content/app/content_main_runner.cc b/content/app/content_main_runner.cc
index 9031eef..05e45bd 100644
--- a/content/app/content_main_runner.cc
+++ b/content/app/content_main_runner.cc
@@ -50,6 +50,10 @@
#include "ui/base/ui_base_paths.h"
#include "ui/base/ui_base_switches.h"
+#ifdef V8_USE_EXTERNAL_STARTUP_DATA
+#include "gin/public/isolate_holder.h"
+#endif
+
#if defined(OS_ANDROID)
#include "content/public/common/content_descriptors.h"
#endif
@@ -716,9 +720,26 @@ class ContentMainRunnerImpl : public ContentMainRunner {
CHECK(base::i18n::InitializeICUWithFileDescriptor(icudata_fd));
else
CHECK(base::i18n::InitializeICU());
+
+#ifdef V8_USE_EXTERNAL_STARTUP_DATA
+ int v8_natives_fd = base::GlobalDescriptors::GetInstance()->MaybeGet(
+ kV8NativesDataDescriptor);
+ int v8_snapshot_fd = base::GlobalDescriptors::GetInstance()->MaybeGet(
+ kV8SnapshotDataDescriptor);
+ if (v8_natives_fd != -1 && v8_snapshot_fd != -1) {
+ CHECK(gin::IsolateHolder::LoadV8SnapshotFD(v8_natives_fd,
+ v8_snapshot_fd));
+ } else {
+ CHECK(gin::IsolateHolder::LoadV8Snapshot());
+ }
+#endif // V8_USE_EXTERNAL_STARTUP_DATA
+
#else
CHECK(base::i18n::InitializeICU());
-#endif
+#ifdef V8_USE_EXTERNAL_STARTUP_DATA
+ CHECK(gin::IsolateHolder::LoadV8Snapshot());
+#endif // V8_USE_EXTERNAL_STARTUP_DATA
+#endif // OS_ANDROID
InitializeStatsTable(command_line);
diff --git a/content/content.gyp b/content/content.gyp
index 5d843b64..6957c4c 100644
--- a/content/content.gyp
+++ b/content/content.gyp
@@ -575,6 +575,23 @@
}],
],
},
+ {
+ 'target_name': 'content_v8_external_data',
+ 'type': 'none',
+ 'conditions': [
+ ['v8_use_external_startup_data==1', {
+ 'copies': [
+ {
+ 'destination': '<(PRODUCT_DIR)/content_shell/assets',
+ 'files': [
+ '<(PRODUCT_DIR)/natives_blob.bin',
+ '<(PRODUCT_DIR)/snapshot_blob.bin',
+ ],
+ },
+ ],
+ }],
+ ],
+ },
],
}], # OS == "android"
],
diff --git a/content/content_browsertests.isolate b/content/content_browsertests.isolate
index ea3cf07..53a53fc 100644
--- a/content/content_browsertests.isolate
+++ b/content/content_browsertests.isolate
@@ -124,5 +124,6 @@
],
'includes': [
'../base/base.isolate',
+ '../gin/v8.isolate',
],
}
diff --git a/content/content_gl_tests.isolate b/content/content_gl_tests.isolate
index d5ff6d7..a9ca4e3 100644
--- a/content/content_gl_tests.isolate
+++ b/content/content_gl_tests.isolate
@@ -52,5 +52,6 @@
],
'includes': [
'../base/base.isolate',
+ '../gin/v8.isolate',
],
}
diff --git a/content/content_shell.gypi b/content/content_shell.gypi
index e98d570..a3e8112 100644
--- a/content/content_shell.gypi
+++ b/content/content_shell.gypi
@@ -1050,6 +1050,7 @@
'dependencies': [
'content.gyp:content_icudata',
'content.gyp:content_java',
+ 'content.gyp:content_v8_external_data',
'content_java_test_support',
'content_shell_java',
'libcontent_shell_content_view',
@@ -1075,6 +1076,12 @@
'<(PRODUCT_DIR)/icudtl.dat',
],
}],
+ ['v8_use_external_startup_data==1', {
+ 'additional_input_paths': [
+ '<(PRODUCT_DIR)/natives_blob.bin',
+ '<(PRODUCT_DIR)/snapshot_blob.bin',
+ ],
+ }],
],
},
'conditions': [
diff --git a/content/content_tests.gypi b/content/content_tests.gypi
index ab604b4..03c64ce 100644
--- a/content/content_tests.gypi
+++ b/content/content_tests.gypi
@@ -337,7 +337,9 @@
}],
['OS=="android"', {
'dependencies': [
+ '../gin/gin.gyp:gin',
'../ui/shell_dialogs/shell_dialogs.gyp:shell_dialogs',
+ 'content.gyp:content_v8_external_data',
],
}],
],
@@ -1633,6 +1635,23 @@
],
'variables': {
'test_suite_name': 'content_unittests',
+ 'conditions': [
+ ['v8_use_external_startup_data==1', {
+ 'additional_input_paths': [
+ '<(PRODUCT_DIR)/natives_blob.bin',
+ '<(PRODUCT_DIR)/snapshot_blob.bin',
+ ],
+ 'copies': [
+ {
+ 'destination': '<(PRODUCT_DIR)/content_unittests_apk/assets',
+ 'files': [
+ '<(PRODUCT_DIR)/natives_blob.bin',
+ '<(PRODUCT_DIR)/snapshot_blob.bin',
+ ],
+ },
+ ],
+ }],
+ ],
},
'includes': [ '../build/apk_test.gypi' ],
},
@@ -1643,6 +1662,7 @@
'dependencies': [
'content.gyp:content_icudata',
'content.gyp:content_java',
+ 'content.gyp:content_v8_external_data',
'content_browsertests',
'content_java_test_support',
'content_shell_java',
@@ -1660,6 +1680,12 @@
'<(PRODUCT_DIR)/icudtl.dat',
],
}],
+ ['v8_use_external_startup_data==1', {
+ 'additional_input_paths': [
+ '<(PRODUCT_DIR)/natives_blob.bin',
+ '<(PRODUCT_DIR)/snapshot_blob.bin',
+ ],
+ }],
],
},
'includes': [ '../build/java_apk.gypi' ],
@@ -1687,6 +1713,7 @@
'chromium_android_linker_test',
'content.gyp:content_icudata',
'content.gyp:content_java',
+ 'content.gyp:content_v8_external_data',
'content_shell_java',
],
'variables': {
@@ -1704,6 +1731,12 @@
'<(PRODUCT_DIR)/icudtl.dat',
],
}],
+ ['v8_use_external_startup_data==1', {
+ 'additional_input_paths': [
+ '<(PRODUCT_DIR)/natives_blob.bin',
+ '<(PRODUCT_DIR)/snapshot_blob.bin',
+ ],
+ }],
],
},
'includes': [ '../build/java_apk.gypi' ],
diff --git a/content/content_unittests.isolate b/content/content_unittests.isolate
index 184f7c5..72d8d3d 100644
--- a/content/content_unittests.isolate
+++ b/content/content_unittests.isolate
@@ -114,5 +114,6 @@
],
'includes': [
'../base/base.isolate',
+ '../gin/v8.isolate',
],
}
diff --git a/content/public/common/content_descriptors.h b/content/public/common/content_descriptors.h
index 5a6b234..db97201 100644
--- a/content/public/common/content_descriptors.h
+++ b/content/public/common/content_descriptors.h
@@ -16,6 +16,12 @@ enum {
#if defined(OS_ANDROID)
kAndroidPropertyDescriptor,
kAndroidICUDataDescriptor,
+
+#ifdef V8_USE_EXTERNAL_STARTUP_DATA
+ kV8NativesDataDescriptor,
+ kV8SnapshotDataDescriptor,
+#endif
+
#endif
// The first key that embedders can use to register descriptors (see
diff --git a/content/public/test/DEPS b/content/public/test/DEPS
index 9c458aa..43a7d3c 100644
--- a/content/public/test/DEPS
+++ b/content/public/test/DEPS
@@ -9,6 +9,7 @@ specific_include_rules = {
".*\.cc": [
# Testing utilities can access anything in content/
"+content",
+ "+gin/public/isolate_holder.h",
"+media/base",
"+third_party/iaccessible2",
"+ui/base/resource/resource_bundle.h",
diff --git a/content/public/test/content_test_suite_base.cc b/content/public/test/content_test_suite_base.cc
index 70666e5..9b11678 100644
--- a/content/public/test/content_test_suite_base.cc
+++ b/content/public/test/content_test_suite_base.cc
@@ -37,6 +37,10 @@
#include "ui/shell_dialogs/android/shell_dialogs_jni_registrar.h"
#endif
+#ifdef V8_USE_EXTERNAL_STARTUP_DATA
+#include "gin/public/isolate_holder.h"
+#endif
+
namespace content {
class ContentTestSuiteBaseListener : public testing::EmptyTestEventListener {
@@ -62,6 +66,10 @@ void ContentTestSuiteBase::Initialize() {
// by tests.
base::StatisticsRecorder::Initialize();
+#ifdef V8_USE_EXTERNAL_STARTUP_DATA
+ gin::IsolateHolder::LoadV8Snapshot();
+#endif
+
#if defined(OS_ANDROID)
// Register JNI bindings for android.
JNIEnv* env = base::android::AttachCurrentThread();
diff --git a/content/shell/android/browsertests_apk/src/org/chromium/content_browsertests_apk/ContentBrowserTestsApplication.java b/content/shell/android/browsertests_apk/src/org/chromium/content_browsertests_apk/ContentBrowserTestsApplication.java
index 0efb5b2..1343101 100644
--- a/content/shell/android/browsertests_apk/src/org/chromium/content_browsertests_apk/ContentBrowserTestsApplication.java
+++ b/content/shell/android/browsertests_apk/src/org/chromium/content_browsertests_apk/ContentBrowserTestsApplication.java
@@ -16,7 +16,9 @@ public class ContentBrowserTestsApplication extends Application {
private static final String[] MANDATORY_PAK_FILES = new String[] {
"content_shell.pak",
- "icudtl.dat"
+ "icudtl.dat",
+ "natives_blob.bin",
+ "snapshot_blob.bin"
};
private static final String PRIVATE_DATA_DIRECTORY_SUFFIX = "content_shell";
diff --git a/content/shell/android/linker_test_apk/src/org/chromium/chromium_linker_test_apk/ChromiumLinkerTestApplication.java b/content/shell/android/linker_test_apk/src/org/chromium/chromium_linker_test_apk/ChromiumLinkerTestApplication.java
index d996fa7..cf72619 100644
--- a/content/shell/android/linker_test_apk/src/org/chromium/chromium_linker_test_apk/ChromiumLinkerTestApplication.java
+++ b/content/shell/android/linker_test_apk/src/org/chromium/chromium_linker_test_apk/ChromiumLinkerTestApplication.java
@@ -19,10 +19,16 @@ public class ChromiumLinkerTestApplication extends Application {
* operation. We use to link it statically to our binary, but not any more
* so that we have to install it along with other mandatory pak files.
* See src/third_party/icu/README.chromium.
+ *
+ * V8's initial snapshot used to be statically linked to the binary, but
+ * now it's loaded from external files. Therefore we need to install such
+ * snapshots (natives_blob.bin and snapshot.bin) along with pak files.
*/
private static final String[] MANDATORY_PAK_FILES = new String[] {
"content_shell.pak",
- "icudtl.dat"
+ "icudtl.dat",
+ "natives_blob.bin",
+ "snapshot_blob.bin"
};
private static final String PRIVATE_DATA_DIRECTORY_SUFFIX = "chromium_linker_test";
diff --git a/content/shell/android/shell_apk/src/org/chromium/content_shell_apk/ContentShellApplication.java b/content/shell/android/shell_apk/src/org/chromium/content_shell_apk/ContentShellApplication.java
index c430baf..5053e32 100644
--- a/content/shell/android/shell_apk/src/org/chromium/content_shell_apk/ContentShellApplication.java
+++ b/content/shell/android/shell_apk/src/org/chromium/content_shell_apk/ContentShellApplication.java
@@ -22,10 +22,16 @@ public class ContentShellApplication extends ContentApplication {
* operation. We use to link it statically to our binary, but not any more
* so that we have to install it along with other mandatory pak files.
* See src/third_party/icu/README.chromium.
+ *
+ * V8's initial snapshot used to be statically linked to the binary, but
+ * now it's loaded from external files. Therefore we need to install such
+ * snapshots (natives_blob.bin and snapshot.bin) along with pak files.
*/
private static final String[] MANDATORY_PAK_FILES = new String[] {
"content_shell.pak",
- "icudtl.dat"
+ "icudtl.dat",
+ "natives_blob.bin",
+ "snapshot_blob.bin"
};
private static final String PRIVATE_DATA_DIRECTORY_SUFFIX = "content_shell";
diff --git a/content/test/DEPS b/content/test/DEPS
index 4a3e002..7d1b3d9 100644
--- a/content/test/DEPS
+++ b/content/test/DEPS
@@ -3,6 +3,8 @@ include_rules = [
"+chromeos/audio", # For WebRTC tests.
# Testing utilities can access anything in content/
"+content",
+ # For loading V8's initial snapshot from external files.
+ "+gin/public/isolate_holder.h",
"+media/audio", # For AudioParameters in WebRTC tests.
"+media/base", # For ChannelLayout in WebRTC tests.
"+ui/base/resource/data_pack.h",
diff --git a/content/test/content_test_launcher.cc b/content/test/content_test_launcher.cc
index e19db37..82466e7 100644
--- a/content/test/content_test_launcher.cc
+++ b/content/test/content_test_launcher.cc
@@ -21,6 +21,10 @@
#include "media/base/media_switches.h"
#include "testing/gtest/include/gtest/gtest.h"
+#ifdef V8_USE_EXTERNAL_STARTUP_DATA
+#include "gin/public/isolate_holder.h"
+#endif
+
#if defined(OS_ANDROID)
#include "base/message_loop/message_loop.h"
#include "content/app/mojo/mojo_init.h"
@@ -53,6 +57,10 @@ class ContentBrowserTestSuite : public ContentTestSuiteBase {
base::i18n::AllowMultipleInitializeCallsForTesting();
base::i18n::InitializeICU();
+#ifdef V8_USE_EXTERNAL_STARTUP_DATA
+ gin::IsolateHolder::LoadV8Snapshot();
+#endif
+
// This needs to be done before base::TestSuite::Initialize() is called,
// as it also tries to set MessagePumpForUIFactory.
if (!base::MessageLoop::InitMessagePumpForUIFactory(
diff --git a/content/test/test_blink_web_unit_test_support.cc b/content/test/test_blink_web_unit_test_support.cc
index 8f743ed..0fed5ab 100644
--- a/content/test/test_blink_web_unit_test_support.cc
+++ b/content/test/test_blink_web_unit_test_support.cc
@@ -38,6 +38,10 @@
#include "base/mac/scoped_nsautorelease_pool.h"
#endif
+#ifdef V8_USE_EXTERNAL_STARTUP_DATA
+#include "gin/public/isolate_holder.h"
+#endif
+
namespace content {
TestBlinkWebUnitTestSupport::TestBlinkWebUnitTestSupport() {
@@ -54,6 +58,10 @@ TestBlinkWebUnitTestSupport::TestBlinkWebUnitTestSupport() {
new base::StatsTable(base::StatsTable::TableIdentifier(), 20, 200));
base::StatsTable::set_current(stats_table_.get());
+#ifdef V8_USE_EXTERNAL_STARTUP_DATA
+ gin::IsolateHolder::LoadV8Snapshot();
+#endif
+
blink::initialize(this);
blink::mainThreadIsolate()->SetCounterFunction(
base::StatsTable::FindLocation);
diff --git a/gin/isolate_holder.cc b/gin/isolate_holder.cc
index 740e136..334c0e0 100644
--- a/gin/isolate_holder.cc
+++ b/gin/isolate_holder.cc
@@ -18,6 +18,11 @@
#include "gin/public/v8_platform.h"
#include "gin/run_microtasks_observer.h"
+#ifdef V8_USE_EXTERNAL_STARTUP_DATA
+#include "base/files/memory_mapped_file.h"
+#include "base/path_service.h"
+#endif // V8_USE_EXTERNAL_STARTUP_DATA
+
namespace gin {
namespace {
@@ -29,8 +34,70 @@ bool GenerateEntropy(unsigned char* buffer, size_t amount) {
return true;
}
+#ifdef V8_USE_EXTERNAL_STARTUP_DATA
+base::MemoryMappedFile* g_mapped_natives = NULL;
+base::MemoryMappedFile* g_mapped_snapshot = NULL;
+
+bool MapV8Files(base::FilePath* natives_path, base::FilePath* snapshot_path,
+ int natives_fd = -1, int snapshot_fd = -1) {
+ int flags = base::File::FLAG_OPEN | base::File::FLAG_READ;
+
+ g_mapped_natives = new base::MemoryMappedFile;
+ if (!g_mapped_natives->IsValid()) {
+ if (natives_fd == -1
+ ? !g_mapped_natives->Initialize(base::File(*natives_path, flags))
+ : !g_mapped_natives->Initialize(base::File(natives_fd))) {
+ delete g_mapped_natives;
+ g_mapped_natives = NULL;
+ LOG(FATAL) << "Couldn't mmap v8 natives data file";
+ return false;
+ }
+ }
+
+ g_mapped_snapshot = new base::MemoryMappedFile;
+ if (!g_mapped_snapshot->IsValid()) {
+ if (snapshot_fd == -1
+ ? !g_mapped_snapshot->Initialize(base::File(*snapshot_path, flags))
+ : !g_mapped_snapshot->Initialize(base::File(snapshot_fd))) {
+ delete g_mapped_snapshot;
+ g_mapped_snapshot = NULL;
+ LOG(ERROR) << "Couldn't mmap v8 snapshot data file";
+ return false;
+ }
+ }
+
+ return true;
+}
+#endif // V8_USE_EXTERNAL_STARTUP_DATA
+
} // namespace
+
+#ifdef V8_USE_EXTERNAL_STARTUP_DATA
+// static
+bool IsolateHolder::LoadV8Snapshot() {
+ if (g_mapped_natives && g_mapped_snapshot)
+ return true;
+
+ base::FilePath data_path;
+ PathService::Get(base::DIR_ANDROID_APP_DATA, &data_path);
+ DCHECK(!data_path.empty());
+
+ base::FilePath natives_path = data_path.AppendASCII("natives_blob.bin");
+ base::FilePath snapshot_path = data_path.AppendASCII("snapshot_blob.bin");
+
+ return MapV8Files(&natives_path, &snapshot_path);
+}
+
+//static
+bool IsolateHolder::LoadV8SnapshotFD(int natives_fd, int snapshot_fd) {
+ if (g_mapped_natives && g_mapped_snapshot)
+ return true;
+
+ return MapV8Files(NULL, NULL, natives_fd, snapshot_fd);
+}
+#endif // V8_USE_EXTERNAL_STARTUP_DATA
+
IsolateHolder::IsolateHolder() {
CHECK(g_array_buffer_allocator)
<< "You need to invoke gin::IsolateHolder::Initialize first";
@@ -88,6 +155,19 @@ void IsolateHolder::Initialize(ScriptMode mode,
v8::V8::SetFlagsFromString(v8_flags, sizeof(v8_flags) - 1);
}
v8::V8::SetEntropySource(&GenerateEntropy);
+#ifdef V8_USE_EXTERNAL_STARTUP_DATA
+ v8::StartupData natives;
+ natives.data = reinterpret_cast<const char*>(g_mapped_natives->data());
+ natives.raw_size = g_mapped_natives->length();
+ natives.compressed_size = g_mapped_natives->length();
+ v8::V8::SetNativesDataBlob(&natives);
+
+ v8::StartupData snapshot;
+ snapshot.data = reinterpret_cast<const char*>(g_mapped_snapshot->data());
+ snapshot.raw_size = g_mapped_snapshot->length();
+ snapshot.compressed_size = g_mapped_snapshot->length();
+ v8::V8::SetSnapshotDataBlob(&snapshot);
+#endif // V8_USE_EXTERNAL_STARTUP_DATA
v8::V8::Initialize();
v8_is_initialized = true;
}
diff --git a/gin/public/isolate_holder.h b/gin/public/isolate_holder.h
index 29cc208..4e14ade 100644
--- a/gin/public/isolate_holder.h
+++ b/gin/public/isolate_holder.h
@@ -31,7 +31,9 @@ class GIN_EXPORT IsolateHolder {
~IsolateHolder();
// Should be invoked once before creating IsolateHolder instances to
- // initialize V8 and Gin.
+ // initialize V8 and Gin. In case V8_USE_EXTERNAL_STARTUP_DATA is defined,
+ // V8's initial snapshot should be loaded (by calling LoadV8Snapshot or
+ // LoadV8SnapshotFD) before calling Initialize.
static void Initialize(ScriptMode mode,
v8::ArrayBuffer::Allocator* allocator);
@@ -49,6 +51,13 @@ class GIN_EXPORT IsolateHolder {
// thread.
void RemoveRunMicrotasksObserver();
+#ifdef V8_USE_EXTERNAL_STARTUP_DATA
+#ifdef OS_ANDROID
+ static bool LoadV8SnapshotFD(int natives_fd, int snapshot_fd);
+#endif
+ static bool LoadV8Snapshot();
+#endif // V8_USE_EXTERNAL_STARTUP_DATA
+
private:
v8::Isolate* isolate_;
scoped_ptr<PerIsolateData> isolate_data_;
diff --git a/gin/shell/gin_main.cc b/gin/shell/gin_main.cc
index b17ec0a..2f7998e 100644
--- a/gin/shell/gin_main.cc
+++ b/gin/shell/gin_main.cc
@@ -60,6 +60,9 @@ int main(int argc, char** argv) {
base::AtExitManager at_exit;
CommandLine::Init(argc, argv);
base::i18n::InitializeICU();
+#ifdef V8_USE_EXTERNAL_STARTUP_DATA
+ gin::IsolateHolder::LoadV8Snapshot();
+#endif
gin::IsolateHolder::Initialize(gin::IsolateHolder::kStrictMode,
gin::ArrayBufferAllocator::SharedInstance());
diff --git a/gin/shell_runner_unittest.cc b/gin/shell_runner_unittest.cc
index 07ab678..7134de1 100644
--- a/gin/shell_runner_unittest.cc
+++ b/gin/shell_runner_unittest.cc
@@ -10,6 +10,10 @@
#include "gin/public/isolate_holder.h"
#include "testing/gtest/include/gtest/gtest.h"
+#ifdef V8_USE_EXTERNAL_STARTUP_DATA
+#include "gin/public/isolate_holder.h"
+#endif
+
using v8::Isolate;
using v8::Object;
using v8::Script;
@@ -20,6 +24,10 @@ namespace gin {
TEST(RunnerTest, Run) {
std::string source = "this.result = 'PASS';\n";
+#ifdef V8_USE_EXTERNAL_STARTUP_DATA
+ gin::IsolateHolder::LoadV8Snapshot();
+#endif
+
gin::IsolateHolder::Initialize(gin::IsolateHolder::kStrictMode,
gin::ArrayBufferAllocator::SharedInstance());
gin::IsolateHolder instance;
diff --git a/gin/test/file_runner.cc b/gin/test/file_runner.cc
index 83228d6..b639d06 100644
--- a/gin/test/file_runner.cc
+++ b/gin/test/file_runner.cc
@@ -19,6 +19,10 @@
#include "gin/try_catch.h"
#include "testing/gtest/include/gtest/gtest.h"
+#ifdef V8_USE_EXTERNAL_STARTUP_DATA
+#include "gin/public/isolate_holder.h"
+#endif
+
namespace gin {
namespace {
@@ -58,6 +62,10 @@ void RunTestFromFile(const base::FilePath& path, FileRunnerDelegate* delegate,
base::MessageLoop message_loop;
+#ifdef V8_USE_EXTERNAL_STARTUP_DATA
+ gin::IsolateHolder::LoadV8Snapshot();
+#endif
+
gin::IsolateHolder::Initialize(gin::IsolateHolder::kStrictMode,
gin::ArrayBufferAllocator::SharedInstance());
gin::IsolateHolder instance;
diff --git a/gin/test/v8_test.cc b/gin/test/v8_test.cc
index cb6d573..a022511 100644
--- a/gin/test/v8_test.cc
+++ b/gin/test/v8_test.cc
@@ -7,6 +7,10 @@
#include "gin/array_buffer.h"
#include "gin/public/isolate_holder.h"
+#ifdef V8_USE_EXTERNAL_STARTUP_DATA
+#include "gin/public/isolate_holder.h"
+#endif
+
using v8::Context;
using v8::Local;
using v8::HandleScope;
@@ -20,6 +24,9 @@ V8Test::~V8Test() {
}
void V8Test::SetUp() {
+#ifdef V8_USE_EXTERNAL_STARTUP_DATA
+ gin::IsolateHolder::LoadV8Snapshot();
+#endif
gin::IsolateHolder::Initialize(gin::IsolateHolder::kStrictMode,
gin::ArrayBufferAllocator::SharedInstance());
instance_.reset(new gin::IsolateHolder);
diff --git a/gin/v8.isolate b/gin/v8.isolate
new file mode 100644
index 0000000..14d8a2c
--- /dev/null
+++ b/gin/v8.isolate
@@ -0,0 +1,15 @@
+# Copyright 2014 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+{
+ 'conditions': [
+ ['v8_use_external_startup_data==1', {
+ 'variables': {
+ 'isolate_dependency_tracked': [
+ '<(PRODUCT_DIR)/natives_blob.bin',
+ '<(PRODUCT_DIR)/snapshot_blob.bin',
+ ],
+ },
+ }],
+ ],
+}
diff --git a/net/net.gyp b/net/net.gyp
index e570e8e..f762ad6 100644
--- a/net/net.gyp
+++ b/net/net.gyp
@@ -789,6 +789,11 @@
],
},
],
+ ['v8_use_external_startup_data==1', {
+ 'dependencies': [
+ '../gin/gin.gyp:gin',
+ ]
+ }],
],
'target_conditions': [
# These source files are excluded by default platform rules, but they
@@ -1651,6 +1656,23 @@
],
'variables': {
'test_suite_name': 'net_unittests',
+ 'conditions': [
+ ['v8_use_external_startup_data==1', {
+ 'additional_input_paths': [
+ '<(PRODUCT_DIR)/natives_blob.bin',
+ '<(PRODUCT_DIR)/snapshot_blob.bin',
+ ],
+ 'copies': [
+ {
+ 'destination': '<(PRODUCT_DIR)/net_unittests_apk/assets',
+ 'files': [
+ '<(PRODUCT_DIR)/natives_blob.bin',
+ '<(PRODUCT_DIR)/snapshot_blob.bin',
+ ],
+ },
+ ],
+ }],
+ ],
},
'includes': [ '../build/apk_test.gypi' ],
},
diff --git a/net/net.isolate b/net/net.isolate
index f5ca9b5..cd2d266 100644
--- a/net/net.isolate
+++ b/net/net.isolate
@@ -6,5 +6,6 @@
],
'includes': [
'../base/base.isolate',
+ '../gin/v8.isolate',
],
}
diff --git a/net/net_unittests.isolate b/net/net_unittests.isolate
index 15b3f08..e57f957 100644
--- a/net/net_unittests.isolate
+++ b/net/net_unittests.isolate
@@ -42,5 +42,6 @@
],
'includes': [
'../base/base.isolate',
+ '../gin/v8.isolate',
],
}
diff --git a/net/test/run_all_unittests.cc b/net/test/run_all_unittests.cc
index a035057..12df717 100644
--- a/net/test/run_all_unittests.cc
+++ b/net/test/run_all_unittests.cc
@@ -23,6 +23,10 @@
#include "net/proxy/proxy_resolver_v8.h"
#endif
+#ifdef V8_USE_EXTERNAL_STARTUP_DATA
+#include "gin/public/isolate_holder.h"
+#endif
+
using net::internal::ClientSocketPoolBaseHelper;
using net::SpdySession;
@@ -57,6 +61,10 @@ int main(int argc, char** argv) {
// single-threaded.
net::EnableSSLServerSockets();
+#ifdef V8_USE_EXTERNAL_STARTUP_DATA
+ gin::IsolateHolder::LoadV8Snapshot();
+#endif
+
#if !defined(OS_IOS)
net::ProxyResolverV8::EnsureIsolateCreated();
#endif
diff --git a/testing/android/java/src/org/chromium/native_test/ChromeNativeTestActivity.java b/testing/android/java/src/org/chromium/native_test/ChromeNativeTestActivity.java
index 9b241d1..f5d381a 100644
--- a/testing/android/java/src/org/chromium/native_test/ChromeNativeTestActivity.java
+++ b/testing/android/java/src/org/chromium/native_test/ChromeNativeTestActivity.java
@@ -36,7 +36,7 @@ public class ChromeNativeTestActivity extends Activity {
PathUtils.setPrivateDataDirectorySuffix("chrome");
ResourceExtractor resourceExtractor = ResourceExtractor.get(getApplicationContext());
- resourceExtractor.setExtractAllPaksForTesting();
+ resourceExtractor.setExtractAllPaksAndV8SnapshotForTesting();
resourceExtractor.startExtractingResources();
resourceExtractor.waitForCompletion();
diff --git a/third_party/android_webview_glue/android_webview_glue.gypi b/third_party/android_webview_glue/android_webview_glue.gypi
index 3ba317a..098a6fd 100644
--- a/third_party/android_webview_glue/android_webview_glue.gypi
+++ b/third_party/android_webview_glue/android_webview_glue.gypi
@@ -19,6 +19,12 @@
'<(PRODUCT_DIR)/icudtl.dat',
],
}],
+ ['v8_use_external_startup_data==1', {
+ 'files': [
+ '<(PRODUCT_DIR)/natives_blob.bin',
+ '<(PRODUCT_DIR)/snapshot_blob.bin',
+ ],
+ }],
],
},
],
diff --git a/third_party/android_webview_glue/android_webview_glue_common.gypi b/third_party/android_webview_glue/android_webview_glue_common.gypi
index 896dee4..2b818e2 100644
--- a/third_party/android_webview_glue/android_webview_glue_common.gypi
+++ b/third_party/android_webview_glue/android_webview_glue_common.gypi
@@ -31,6 +31,12 @@
'<(PRODUCT_DIR)/icudtl.dat',
],
}],
+ ['v8_use_external_startup_data==1', {
+ 'additional_input_paths': [
+ '<(PRODUCT_DIR)/natives_blob.bin',
+ '<(PRODUCT_DIR)/snapshot_blob.bin',
+ ],
+ }],
],
},
'includes': [ '../../build/java_apk.gypi' ],
diff --git a/tools/gypv8sh.py b/tools/gypv8sh.py
index 3f81a8b..9724ed4 100755
--- a/tools/gypv8sh.py
+++ b/tools/gypv8sh.py
@@ -26,6 +26,8 @@ def main ():
parser.add_option('--deps_js', action="store",
help=("Path to deps.js for dependency resolution, " +
"optional."))
+ parser.add_option('--external', action='store',
+ help="Load V8's initial snapshot from external files (y/n)")
(opts, args) = parser.parse_args()
if len(args) != 9:
@@ -36,6 +38,12 @@ def main ():
icudatafile = os.path.join(os.path.dirname(v8_shell), 'icudtl.dat')
if os.path.exists(icudatafile):
cmd.extend(['--icu-data-file=%s' % icudatafile])
+ v8nativesfile = os.path.join(os.path.dirname(v8_shell), 'natives_blob.bin')
+ if opts.external == 'y' and os.path.exists(v8nativesfile):
+ cmd.extend(['--natives_blob=%s' % v8nativesfile])
+ v8snapshotfile = os.path.join(os.path.dirname(v8_shell), 'snapshot_blob.bin')
+ if opts.external == 'y' and os.path.exists(v8snapshotfile):
+ cmd.extend(['--snapshot_blob=%s' % v8snapshotfile])
arguments = [js2webui, inputfile, inputrelfile, opts.deps_js,
cxxoutfile, test_type]
cmd.extend(['-e', "arguments=" + json.dumps(arguments), mock_js,