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( ...@@ -424,6 +424,9 @@ void SetRuntimeFeaturesDefaultsAndUpdateFromArgs(
WebRuntimeFeatures::EnablePictureInPicture( WebRuntimeFeatures::EnablePictureInPicture(
base::FeatureList::IsEnabled(media::kPictureInPicture)); base::FeatureList::IsEnabled(media::kPictureInPicture));
WebRuntimeFeatures::EnableCodeCacheAfterExecute(
base::FeatureList::IsEnabled(features::kCodeCacheAfterExecute));
}; };
} // namespace content } // namespace content
...@@ -564,4 +564,8 @@ bool IsVideoCaptureServiceEnabledForBrowserProcess() { ...@@ -564,4 +564,8 @@ bool IsVideoCaptureServiceEnabledForBrowserProcess() {
#endif #endif
} }
// Enables code caching after executing the script.
const base::Feature kCodeCacheAfterExecute{"CodeCacheAfterExecute",
base::FEATURE_DISABLED_BY_DEFAULT};
} // namespace features } // namespace features
...@@ -102,6 +102,7 @@ CONTENT_EXPORT extern const base::Feature kUserActivationV2; ...@@ -102,6 +102,7 @@ CONTENT_EXPORT extern const base::Feature kUserActivationV2;
CONTENT_EXPORT extern const base::Feature kV8ContextSnapshot; CONTENT_EXPORT extern const base::Feature kV8ContextSnapshot;
CONTENT_EXPORT extern const base::Feature kV8BackgroundCompile; CONTENT_EXPORT extern const base::Feature kV8BackgroundCompile;
CONTENT_EXPORT extern const base::Feature kV8VmFuture; 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 kVibrateRequiresUserGesture;
CONTENT_EXPORT extern const base::Feature kWebAssembly; CONTENT_EXPORT extern const base::Feature kWebAssembly;
CONTENT_EXPORT extern const base::Feature kWebAssemblyStreaming; CONTENT_EXPORT extern const base::Feature kWebAssemblyStreaming;
......
...@@ -145,14 +145,23 @@ v8::Local<v8::Value> ScriptController::ExecuteScriptAndReturnValue( ...@@ -145,14 +145,23 @@ v8::Local<v8::Value> ScriptController::ExecuteScriptAndReturnValue(
.ToLocal(&script)) .ToLocal(&script))
return result; return result;
v8::MaybeLocal<v8::Value> maybe_result;
if (RuntimeEnabledFeatures::CodeCacheAfterExecuteEnabled()) {
maybe_result = V8ScriptRunner::RunCompiledScript(
GetIsolate(), script, GetFrame()->GetDocument());
V8ScriptRunner::ProduceCache(GetIsolate(), script, source, V8ScriptRunner::ProduceCache(GetIsolate(), script, source,
produce_cache_options, compile_options); 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, if (!maybe_result.ToLocal(&result)) {
GetFrame()->GetDocument())
.ToLocal(&result))
return result; return result;
} }
}
return result; return result;
} }
......
...@@ -280,10 +280,17 @@ ScriptValue WorkerOrWorkletScriptController::EvaluateInternal( ...@@ -280,10 +280,17 @@ ScriptValue WorkerOrWorkletScriptController::EvaluateInternal(
kSharableCrossOrigin, compile_options, kSharableCrossOrigin, compile_options,
no_cache_reason, referrer_info) no_cache_reason, referrer_info)
.ToLocal(&compiled_script)) { .ToLocal(&compiled_script)) {
if (RuntimeEnabledFeatures::CodeCacheAfterExecuteEnabled()) {
maybe_result = V8ScriptRunner::RunCompiledScript(
isolate_, compiled_script, global_scope_);
V8ScriptRunner::ProduceCache(isolate_, compiled_script, source_code, V8ScriptRunner::ProduceCache(isolate_, compiled_script, source_code,
produce_cache_options, compile_options); produce_cache_options, compile_options);
maybe_result = V8ScriptRunner::RunCompiledScript(isolate_, compiled_script, } else {
global_scope_); V8ScriptRunner::ProduceCache(isolate_, compiled_script, source_code,
produce_cache_options, compile_options);
maybe_result = V8ScriptRunner::RunCompiledScript(
isolate_, compiled_script, global_scope_);
}
} }
if (!block.CanContinue()) { if (!block.CanContinue()) {
......
...@@ -502,4 +502,8 @@ void WebRuntimeFeatures::EnableDoubleTapToJumpOnVideo(bool enable) { ...@@ -502,4 +502,8 @@ void WebRuntimeFeatures::EnableDoubleTapToJumpOnVideo(bool enable) {
RuntimeEnabledFeatures::SetDoubleTapToJumpOnVideoEnabled(enable); RuntimeEnabledFeatures::SetDoubleTapToJumpOnVideoEnabled(enable);
} }
void WebRuntimeFeatures::EnableCodeCacheAfterExecute(bool enable) {
RuntimeEnabledFeatures::SetCodeCacheAfterExecuteEnabled(enable);
}
} // namespace blink } // namespace blink
...@@ -168,6 +168,9 @@ ...@@ -168,6 +168,9 @@
{ {
name: "ClientPlaceholdersForServerLoFi", name: "ClientPlaceholdersForServerLoFi",
}, },
{
name: "CodeCacheAfterExecute"
},
{ {
name: "CompositedSelectionUpdate", name: "CompositedSelectionUpdate",
}, },
......
...@@ -187,6 +187,7 @@ class WebRuntimeFeatures { ...@@ -187,6 +187,7 @@ class WebRuntimeFeatures {
BLINK_PLATFORM_EXPORT static void EnableStopNonTimersInBackground(bool); BLINK_PLATFORM_EXPORT static void EnableStopNonTimersInBackground(bool);
BLINK_PLATFORM_EXPORT static void EnablePWAFullCodeCache(bool); BLINK_PLATFORM_EXPORT static void EnablePWAFullCodeCache(bool);
BLINK_PLATFORM_EXPORT static void EnableDoubleTapToJumpOnVideo(bool); BLINK_PLATFORM_EXPORT static void EnableDoubleTapToJumpOnVideo(bool);
BLINK_PLATFORM_EXPORT static void EnableCodeCacheAfterExecute(bool);
private: private:
WebRuntimeFeatures(); 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