Commit ce90a370 authored by Mythri Alle's avatar Mythri Alle Committed by Commit Bot

Add a feature to enable code caching after execute

This feature is to run a finch experiment to measure the performance
of requesting code cache after execute.

Bug: chromium:783124
Change-Id: I7cc90c3f341c19e3727ad84903a774f8197663f2
Reviewed-on: https://chromium-review.googlesource.com/829093
Commit-Queue: Mythri Alle <mythria@chromium.org>
Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Reviewed-by: default avatarHiroshige Hayashizaki <hiroshige@chromium.org>
Reviewed-by: default avatarKouhei Ueno <kouhei@chromium.org>
Cr-Commit-Position: refs/heads/master@{#532856}
parent 37e1ae1b
......@@ -424,6 +424,9 @@ void SetRuntimeFeaturesDefaultsAndUpdateFromArgs(
WebRuntimeFeatures::EnablePictureInPicture(
base::FeatureList::IsEnabled(media::kPictureInPicture));
WebRuntimeFeatures::EnableCodeCacheAfterExecute(
base::FeatureList::IsEnabled(features::kCodeCacheAfterExecute));
};
} // namespace content
......@@ -564,4 +564,8 @@ bool IsVideoCaptureServiceEnabledForBrowserProcess() {
#endif
}
// Enables code caching after executing the script.
const base::Feature kCodeCacheAfterExecute{"CodeCacheAfterExecute",
base::FEATURE_DISABLED_BY_DEFAULT};
} // namespace features
......@@ -102,6 +102,7 @@ CONTENT_EXPORT extern const base::Feature kUserActivationV2;
CONTENT_EXPORT extern const base::Feature kV8ContextSnapshot;
CONTENT_EXPORT extern const base::Feature kV8BackgroundCompile;
CONTENT_EXPORT extern const base::Feature kV8VmFuture;
CONTENT_EXPORT extern const base::Feature kCodeCacheAfterExecute;
CONTENT_EXPORT extern const base::Feature kVibrateRequiresUserGesture;
CONTENT_EXPORT extern const base::Feature kWebAssembly;
CONTENT_EXPORT extern const base::Feature kWebAssemblyStreaming;
......
......@@ -145,13 +145,22 @@ v8::Local<v8::Value> ScriptController::ExecuteScriptAndReturnValue(
.ToLocal(&script))
return result;
V8ScriptRunner::ProduceCache(GetIsolate(), script, source,
produce_cache_options, compile_options);
v8::MaybeLocal<v8::Value> maybe_result;
if (RuntimeEnabledFeatures::CodeCacheAfterExecuteEnabled()) {
maybe_result = V8ScriptRunner::RunCompiledScript(
GetIsolate(), script, GetFrame()->GetDocument());
V8ScriptRunner::ProduceCache(GetIsolate(), script, source,
produce_cache_options, compile_options);
} else {
V8ScriptRunner::ProduceCache(GetIsolate(), script, source,
produce_cache_options, compile_options);
maybe_result = V8ScriptRunner::RunCompiledScript(
GetIsolate(), script, GetFrame()->GetDocument());
}
if (!V8ScriptRunner::RunCompiledScript(GetIsolate(), script,
GetFrame()->GetDocument())
.ToLocal(&result))
if (!maybe_result.ToLocal(&result)) {
return result;
}
}
return result;
......
......@@ -280,10 +280,17 @@ ScriptValue WorkerOrWorkletScriptController::EvaluateInternal(
kSharableCrossOrigin, compile_options,
no_cache_reason, referrer_info)
.ToLocal(&compiled_script)) {
V8ScriptRunner::ProduceCache(isolate_, compiled_script, source_code,
produce_cache_options, compile_options);
maybe_result = V8ScriptRunner::RunCompiledScript(isolate_, compiled_script,
global_scope_);
if (RuntimeEnabledFeatures::CodeCacheAfterExecuteEnabled()) {
maybe_result = V8ScriptRunner::RunCompiledScript(
isolate_, compiled_script, global_scope_);
V8ScriptRunner::ProduceCache(isolate_, compiled_script, source_code,
produce_cache_options, compile_options);
} else {
V8ScriptRunner::ProduceCache(isolate_, compiled_script, source_code,
produce_cache_options, compile_options);
maybe_result = V8ScriptRunner::RunCompiledScript(
isolate_, compiled_script, global_scope_);
}
}
if (!block.CanContinue()) {
......
......@@ -502,4 +502,8 @@ void WebRuntimeFeatures::EnableDoubleTapToJumpOnVideo(bool enable) {
RuntimeEnabledFeatures::SetDoubleTapToJumpOnVideoEnabled(enable);
}
void WebRuntimeFeatures::EnableCodeCacheAfterExecute(bool enable) {
RuntimeEnabledFeatures::SetCodeCacheAfterExecuteEnabled(enable);
}
} // namespace blink
......@@ -168,6 +168,9 @@
{
name: "ClientPlaceholdersForServerLoFi",
},
{
name: "CodeCacheAfterExecute"
},
{
name: "CompositedSelectionUpdate",
},
......
......@@ -187,6 +187,7 @@ class WebRuntimeFeatures {
BLINK_PLATFORM_EXPORT static void EnableStopNonTimersInBackground(bool);
BLINK_PLATFORM_EXPORT static void EnablePWAFullCodeCache(bool);
BLINK_PLATFORM_EXPORT static void EnableDoubleTapToJumpOnVideo(bool);
BLINK_PLATFORM_EXPORT static void EnableCodeCacheAfterExecute(bool);
private:
WebRuntimeFeatures();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment