From de933c1940092a2e48548f632abb898a7dbd734f Mon Sep 17 00:00:00 2001 From: Leszek Swirski Date: Fri, 3 Apr 2020 17:30:53 +0000 Subject: [PATCH] [v8] Add feature flag for off-thread streaming finalization Adds a feature flag for enabling off-thread finalization of V8 streaming compilation tasks. This feature should reduce main-thread script compilation time. Bug: 1011762 Change-Id: I64bb986e07dae8d68dc61269e69096c368b1aac8 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2135629 Auto-Submit: Leszek Swirski Commit-Queue: Ross McIlroy Reviewed-by: Ross McIlroy Cr-Commit-Position: refs/heads/master@{#756313} --- gin/gin_features.cc | 4 ++++ gin/gin_features.h | 1 + gin/v8_initializer.cc | 7 +++++++ 3 files changed, 12 insertions(+) diff --git a/gin/gin_features.cc b/gin/gin_features.cc index d24cf1e4d28e3d..60f16e5195ac7e 100644 --- a/gin/gin_features.cc +++ b/gin/gin_features.cc @@ -14,6 +14,10 @@ const base::Feature kV8OptimizeJavascript{"V8OptimizeJavascript", const base::Feature kV8FlushBytecode{"V8FlushBytecode", base::FEATURE_ENABLED_BY_DEFAULT}; +// Enables finalizing streaming JS compilations on a background thread. +const base::Feature kV8OffThreadFinalization{"V8OffThreadFinalization", + base::FEATURE_DISABLED_BY_DEFAULT}; + // Enables lazy feedback allocation in V8. const base::Feature kV8LazyFeedbackAllocation{"V8LazyFeedbackAllocation", base::FEATURE_ENABLED_BY_DEFAULT}; diff --git a/gin/gin_features.h b/gin/gin_features.h index 6502de3ad891ef..9a04e51aed9b73 100644 --- a/gin/gin_features.h +++ b/gin/gin_features.h @@ -12,6 +12,7 @@ namespace features { GIN_EXPORT extern const base::Feature kV8OptimizeJavascript; GIN_EXPORT extern const base::Feature kV8FlushBytecode; +GIN_EXPORT extern const base::Feature kV8OffThreadFinalization; GIN_EXPORT extern const base::Feature kV8LazyFeedbackAllocation; GIN_EXPORT extern const base::Feature kV8ConcurrentInlining; GIN_EXPORT extern const base::Feature kV8PerContextMarkingWorklist; diff --git a/gin/v8_initializer.cc b/gin/v8_initializer.cc index 3a3742ed911cf4..2e2e3464a3760c 100644 --- a/gin/v8_initializer.cc +++ b/gin/v8_initializer.cc @@ -211,6 +211,13 @@ void V8Initializer::Initialize(IsolateHolder::ScriptMode mode) { sizeof(no_flush_bytecode) - 1); } + if (base::FeatureList::IsEnabled(features::kV8OffThreadFinalization)) { + static const char finalize_streaming_on_background[] = + "--finalize-streaming-on-background"; + v8::V8::SetFlagsFromString(finalize_streaming_on_background, + sizeof(finalize_streaming_on_background) - 1); + } + if (!base::FeatureList::IsEnabled(features::kV8LazyFeedbackAllocation)) { static const char no_lazy_feedback_allocation[] = "--no-lazy-feedback-allocation";