| OLD | NEW |
| 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> |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 return false; | 221 return false; |
| 222 } | 222 } |
| 223 #endif // V8_VERIFY_EXTERNAL_STARTUP_DATA | 223 #endif // V8_VERIFY_EXTERNAL_STARTUP_DATA |
| 224 #endif // V8_USE_EXTERNAL_STARTUP_DATA | 224 #endif // V8_USE_EXTERNAL_STARTUP_DATA |
| 225 | 225 |
| 226 bool GenerateEntropy(unsigned char* buffer, size_t amount) { | 226 bool GenerateEntropy(unsigned char* buffer, size_t amount) { |
| 227 base::RandBytes(buffer, amount); | 227 base::RandBytes(buffer, amount); |
| 228 return true; | 228 return true; |
| 229 } | 229 } |
| 230 | 230 |
| 231 bool ShouldUseIgnition() { | |
| 232 if (base::FeatureList::IsEnabled(features::kV8Ignition)) return true; | |
| 233 #if defined(OS_ANDROID) | |
| 234 if (base::FeatureList::IsEnabled(features::kV8IgnitionLowEnd) && | |
| 235 base::SysInfo::IsLowEndDevice()) { | |
| 236 return true; | |
| 237 } | |
| 238 #endif | |
| 239 return false; | |
| 240 } | |
| 241 | |
| 242 | |
| 243 } // namespace | 231 } // namespace |
| 244 | 232 |
| 245 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) | 233 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) |
| 246 #if defined(V8_VERIFY_EXTERNAL_STARTUP_DATA) | 234 #if defined(V8_VERIFY_EXTERNAL_STARTUP_DATA) |
| 247 // Defined in gen/gin/v8_snapshot_fingerprint.cc | 235 // Defined in gen/gin/v8_snapshot_fingerprint.cc |
| 248 extern const unsigned char g_natives_fingerprint[]; | 236 extern const unsigned char g_natives_fingerprint[]; |
| 249 extern const unsigned char g_snapshot_fingerprint[]; | 237 extern const unsigned char g_snapshot_fingerprint[]; |
| 250 #endif // V8_VERIFY_EXTERNAL_STARTUP_DATA | 238 #endif // V8_VERIFY_EXTERNAL_STARTUP_DATA |
| 251 | 239 |
| 252 enum LoadV8FileResult { | 240 enum LoadV8FileResult { |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 424 if (IsolateHolder::kStrictMode == mode) { | 412 if (IsolateHolder::kStrictMode == mode) { |
| 425 static const char use_strict[] = "--use_strict"; | 413 static const char use_strict[] = "--use_strict"; |
| 426 v8::V8::SetFlagsFromString(use_strict, sizeof(use_strict) - 1); | 414 v8::V8::SetFlagsFromString(use_strict, sizeof(use_strict) - 1); |
| 427 } | 415 } |
| 428 if (IsolateHolder::kStableAndExperimentalV8Extras == v8_extras_mode) { | 416 if (IsolateHolder::kStableAndExperimentalV8Extras == v8_extras_mode) { |
| 429 static const char flag[] = "--experimental_extras"; | 417 static const char flag[] = "--experimental_extras"; |
| 430 v8::V8::SetFlagsFromString(flag, sizeof(flag) - 1); | 418 v8::V8::SetFlagsFromString(flag, sizeof(flag) - 1); |
| 431 } | 419 } |
| 432 | 420 |
| 433 const char* ignition_enabled_crash_key = "N"; | 421 const char* ignition_enabled_crash_key = "N"; |
| 434 if (ShouldUseIgnition()) { | 422 if (base::FeatureList::IsEnabled(features::kV8Ignition)) { |
| 423 ignition_enabled_crash_key = "Y"; |
| 424 std::string flag("--ignition-staging"); |
| 425 v8::V8::SetFlagsFromString(flag.c_str(), static_cast<int>(flag.size())); |
| 426 } else if (base::FeatureList::IsEnabled(features::kV8IgnitionLowEnd) && |
| 427 base::SysInfo::IsLowEndDevice()) { |
| 435 ignition_enabled_crash_key = "Y"; | 428 ignition_enabled_crash_key = "Y"; |
| 436 std::string flag("--ignition"); | 429 std::string flag("--ignition"); |
| 437 v8::V8::SetFlagsFromString(flag.c_str(), static_cast<int>(flag.size())); | 430 v8::V8::SetFlagsFromString(flag.c_str(), static_cast<int>(flag.size())); |
| 438 | |
| 439 if (base::FeatureList::IsEnabled(features::kV8IgnitionEager)) { | |
| 440 std::string eager_flag("--ignition-eager"); | |
| 441 v8::V8::SetFlagsFromString( | |
| 442 eager_flag.c_str(), static_cast<int>(eager_flag.size())); | |
| 443 } | |
| 444 | |
| 445 if (base::FeatureList::IsEnabled(features::kV8IgnitionLazy)) { | |
| 446 std::string lazy_flag("--no-ignition-eager"); | |
| 447 v8::V8::SetFlagsFromString( | |
| 448 lazy_flag.c_str(), static_cast<int>(lazy_flag.size())); | |
| 449 } | |
| 450 } | 431 } |
| 451 static const char kIgnitionEnabledKey[] = "v8-ignition"; | 432 static const char kIgnitionEnabledKey[] = "v8-ignition"; |
| 452 base::debug::SetCrashKeyValue(kIgnitionEnabledKey, | 433 base::debug::SetCrashKeyValue(kIgnitionEnabledKey, |
| 453 ignition_enabled_crash_key); | 434 ignition_enabled_crash_key); |
| 454 | 435 |
| 455 | 436 |
| 456 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) | 437 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) |
| 457 v8::StartupData natives; | 438 v8::StartupData natives; |
| 458 natives.data = reinterpret_cast<const char*>(g_mapped_natives->data()); | 439 natives.data = reinterpret_cast<const char*>(g_mapped_natives->data()); |
| 459 natives.raw_size = static_cast<int>(g_mapped_natives->length()); | 440 natives.raw_size = static_cast<int>(g_mapped_natives->length()); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 489 *snapshot_data_out = | 470 *snapshot_data_out = |
| 490 reinterpret_cast<const char*>(g_mapped_snapshot->data()); | 471 reinterpret_cast<const char*>(g_mapped_snapshot->data()); |
| 491 *snapshot_size_out = static_cast<int>(g_mapped_snapshot->length()); | 472 *snapshot_size_out = static_cast<int>(g_mapped_snapshot->length()); |
| 492 } else { | 473 } else { |
| 493 *snapshot_data_out = NULL; | 474 *snapshot_data_out = NULL; |
| 494 *snapshot_size_out = 0; | 475 *snapshot_size_out = 0; |
| 495 } | 476 } |
| 496 } | 477 } |
| 497 | 478 |
| 498 } // namespace gin | 479 } // namespace gin |
| OLD | NEW |