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

Side by Side Diff: gin/v8_initializer.cc

Issue 2039793003: [gin] Add V8IgnitionLowEnd experiment (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove crash keys Created 4 years, 6 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 unified diff | Download patch
« no previous file with comments | « gin/public/gin_features.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "gin/v8_initializer.h" 5 #include "gin/v8_initializer.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
11 11
12 #include "base/debug/alias.h" 12 #include "base/debug/alias.h"
13 #include "base/feature_list.h" 13 #include "base/feature_list.h"
14 #include "base/files/file.h" 14 #include "base/files/file.h"
15 #include "base/files/file_path.h" 15 #include "base/files/file_path.h"
16 #include "base/files/memory_mapped_file.h" 16 #include "base/files/memory_mapped_file.h"
17 #include "base/lazy_instance.h" 17 #include "base/lazy_instance.h"
18 #include "base/logging.h" 18 #include "base/logging.h"
19 #include "base/metrics/histogram.h" 19 #include "base/metrics/histogram.h"
20 #include "base/rand_util.h" 20 #include "base/rand_util.h"
21 #include "base/strings/sys_string_conversions.h" 21 #include "base/strings/sys_string_conversions.h"
22 #include "base/sys_info.h"
22 #include "base/threading/platform_thread.h" 23 #include "base/threading/platform_thread.h"
23 #include "base/time/time.h" 24 #include "base/time/time.h"
24 #include "crypto/sha2.h" 25 #include "crypto/sha2.h"
25 #include "gin/public/gin_features.h" 26 #include "gin/public/gin_features.h"
26 27
27 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) 28 #if defined(V8_USE_EXTERNAL_STARTUP_DATA)
28 #if defined(OS_ANDROID) 29 #if defined(OS_ANDROID)
29 #include "base/android/apk_assets.h" 30 #include "base/android/apk_assets.h"
30 #endif 31 #endif
31 #if defined(OS_MACOSX) 32 #if defined(OS_MACOSX)
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 return false; 223 return false;
223 } 224 }
224 #endif // V8_VERIFY_EXTERNAL_STARTUP_DATA 225 #endif // V8_VERIFY_EXTERNAL_STARTUP_DATA
225 #endif // V8_USE_EXTERNAL_STARTUP_DATA 226 #endif // V8_USE_EXTERNAL_STARTUP_DATA
226 227
227 bool GenerateEntropy(unsigned char* buffer, size_t amount) { 228 bool GenerateEntropy(unsigned char* buffer, size_t amount) {
228 base::RandBytes(buffer, amount); 229 base::RandBytes(buffer, amount);
229 return true; 230 return true;
230 } 231 }
231 232
233 bool ShouldUseIgnition() {
234 if (base::FeatureList::IsEnabled(features::kV8Ignition)) return true;
235 #if defined(OS_ANDROID)
236 if (base::FeatureList::IsEnabled(features::kV8IgnitionLowEnd) &&
237 base::SysInfo::IsLowEndDevice()) {
238 return true;
239 }
240 #endif
241 return false;
242 }
243
244
232 } // namespace 245 } // namespace
233 246
234 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) 247 #if defined(V8_USE_EXTERNAL_STARTUP_DATA)
235 #if defined(V8_VERIFY_EXTERNAL_STARTUP_DATA) 248 #if defined(V8_VERIFY_EXTERNAL_STARTUP_DATA)
236 // Defined in gen/gin/v8_snapshot_fingerprint.cc 249 // Defined in gen/gin/v8_snapshot_fingerprint.cc
237 extern const unsigned char g_natives_fingerprint[]; 250 extern const unsigned char g_natives_fingerprint[];
238 extern const unsigned char g_snapshot_fingerprint[]; 251 extern const unsigned char g_snapshot_fingerprint[];
239 #endif // V8_VERIFY_EXTERNAL_STARTUP_DATA 252 #endif // V8_VERIFY_EXTERNAL_STARTUP_DATA
240 253
241 enum LoadV8FileResult { 254 enum LoadV8FileResult {
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 436
424 if (IsolateHolder::kStrictMode == mode) { 437 if (IsolateHolder::kStrictMode == mode) {
425 static const char use_strict[] = "--use_strict"; 438 static const char use_strict[] = "--use_strict";
426 v8::V8::SetFlagsFromString(use_strict, sizeof(use_strict) - 1); 439 v8::V8::SetFlagsFromString(use_strict, sizeof(use_strict) - 1);
427 } 440 }
428 if (IsolateHolder::kStableAndExperimentalV8Extras == v8_extras_mode) { 441 if (IsolateHolder::kStableAndExperimentalV8Extras == v8_extras_mode) {
429 static const char flag[] = "--experimental_extras"; 442 static const char flag[] = "--experimental_extras";
430 v8::V8::SetFlagsFromString(flag, sizeof(flag) - 1); 443 v8::V8::SetFlagsFromString(flag, sizeof(flag) - 1);
431 } 444 }
432 445
433 if (base::FeatureList::IsEnabled(features::kV8Ignition)) { 446 if (ShouldUseIgnition()) {
434 std::string flag("--ignition"); 447 std::string flag("--ignition");
435 v8::V8::SetFlagsFromString(flag.c_str(), static_cast<int>(flag.size())); 448 v8::V8::SetFlagsFromString(flag.c_str(), static_cast<int>(flag.size()));
436 449
437 if (base::FeatureList::IsEnabled(features::kV8IgnitionEager)) { 450 if (base::FeatureList::IsEnabled(features::kV8IgnitionEager)) {
438 std::string eager_flag("--ignition-eager"); 451 std::string eager_flag("--ignition-eager");
439 v8::V8::SetFlagsFromString( 452 v8::V8::SetFlagsFromString(
440 eager_flag.c_str(), static_cast<int>(eager_flag.size())); 453 eager_flag.c_str(), static_cast<int>(eager_flag.size()));
441 } 454 }
442 455
443 if (base::FeatureList::IsEnabled(features::kV8IgnitionLazy)) { 456 if (base::FeatureList::IsEnabled(features::kV8IgnitionLazy)) {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 *snapshot_data_out = 497 *snapshot_data_out =
485 reinterpret_cast<const char*>(g_mapped_snapshot->data()); 498 reinterpret_cast<const char*>(g_mapped_snapshot->data());
486 *snapshot_size_out = static_cast<int>(g_mapped_snapshot->length()); 499 *snapshot_size_out = static_cast<int>(g_mapped_snapshot->length());
487 } else { 500 } else {
488 *snapshot_data_out = NULL; 501 *snapshot_data_out = NULL;
489 *snapshot_size_out = 0; 502 *snapshot_size_out = 0;
490 } 503 }
491 } 504 }
492 505
493 } // namespace gin 506 } // namespace gin
OLDNEW
« no previous file with comments | « gin/public/gin_features.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698