diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp index d31cec4d7d18..54d6fd8c93e0 100644 --- a/dom/base/nsContentUtils.cpp +++ b/dom/base/nsContentUtils.cpp @@ -314,7 +314,6 @@ bool nsContentUtils::sInitialized = false; bool nsContentUtils::sBypassCSSOMOriginCheck = false; #endif -bool nsContentUtils::sIsBytecodeCacheEnabled = false; int32_t nsContentUtils::sBytecodeCacheStrategy = 0; nsCString* nsContentUtils::sJSBytecodeMimeType = nullptr; @@ -612,10 +611,6 @@ nsresult nsContentUtils::Init() { sBypassCSSOMOriginCheck = getenv("MOZ_BYPASS_CSSOM_ORIGIN_CHECK"); #endif - Preferences::AddBoolVarCache(&sIsBytecodeCacheEnabled, - "dom.script_loader.bytecode_cache.enabled", - false); - Preferences::AddBoolVarCache( &sAntiTrackingControlCenterUIEnabled, "browser.contentblocking.rejecttrackers.control-center.ui.enabled", diff --git a/dom/base/nsContentUtils.h b/dom/base/nsContentUtils.h index 4788feeb86d5..181217b016c9 100644 --- a/dom/base/nsContentUtils.h +++ b/dom/base/nsContentUtils.h @@ -3188,10 +3188,6 @@ class nsContentUtils { */ static bool GetUserIsInteracting(); - // Check pref "dom.script_loader.bytecode_cache.enabled" to see - // if we want to cache JS bytecode on the cache entry. - static bool IsBytecodeCacheEnabled() { return sIsBytecodeCacheEnabled; } - // Check pref "dom.script_loader.bytecode_cache.strategy" to see which // heuristic strategy should be used to trigger the caching of the bytecode. static int32_t BytecodeCacheStrategy() { return sBytecodeCacheStrategy; } @@ -3407,7 +3403,6 @@ class nsContentUtils { #ifndef RELEASE_OR_BETA static bool sBypassCSSOMOriginCheck; #endif - static bool sIsBytecodeCacheEnabled; static int32_t sBytecodeCacheStrategy; static bool sAntiTrackingControlCenterUIEnabled; diff --git a/dom/script/ScriptLoadHandler.cpp b/dom/script/ScriptLoadHandler.cpp index 4958bf84500c..f442033e25c9 100644 --- a/dom/script/ScriptLoadHandler.cpp +++ b/dom/script/ScriptLoadHandler.cpp @@ -14,6 +14,7 @@ #include "nsMimeTypes.h" #include "mozilla/Telemetry.h" +#include "mozilla/StaticPrefs.h" namespace mozilla { namespace dom { @@ -407,7 +408,7 @@ ScriptLoadHandler::OnStreamComplete(nsIIncrementalStreamLoader* aLoader, // Everything went well, keep the CacheInfoChannel alive such that we can // later save the bytecode on the cache entry. if (NS_SUCCEEDED(rv) && mRequest->IsSource() && - nsContentUtils::IsBytecodeCacheEnabled()) { + StaticPrefs::dom_script_loader_bytecode_cache_enabled()) { mRequest->mCacheInfo = do_QueryInterface(channelRequest); LOG(("ScriptLoadRequest (%p): nsICacheInfoChannel = %p", mRequest.get(), mRequest->mCacheInfo.get())); diff --git a/dom/script/ScriptLoader.cpp b/dom/script/ScriptLoader.cpp index f08e61af33bd..2cd9ba2215b8 100644 --- a/dom/script/ScriptLoader.cpp +++ b/dom/script/ScriptLoader.cpp @@ -1285,7 +1285,7 @@ nsresult ScriptLoader::StartLoad(ScriptLoadRequest* aRequest) { // constant. aRequest->mCacheInfo = nullptr; nsCOMPtr cic(do_QueryInterface(channel)); - if (cic && nsContentUtils::IsBytecodeCacheEnabled() && + if (cic && StaticPrefs::dom_script_loader_bytecode_cache_enabled() && // Bug 1436400: no bytecode cache support for modules yet. !aRequest->IsModuleRequest()) { if (!aRequest->IsLoadingSource()) { diff --git a/modules/libpref/init/StaticPrefList.h b/modules/libpref/init/StaticPrefList.h index 4f57db022178..0c4444c2a0c6 100644 --- a/modules/libpref/init/StaticPrefList.h +++ b/modules/libpref/init/StaticPrefList.h @@ -538,6 +538,16 @@ VARCACHE_PREF( ) #endif +// Whether to enable the JavaScript start-up cache. This causes one of the first +// execution to record the bytecode of the JavaScript function used, and save it +// in the existing cache entry. On the following loads of the same script, the +// bytecode would be loaded from the cache instead of being generated once more. +VARCACHE_PREF( + "dom.script_loader.bytecode_cache.enabled", + dom_script_loader_bytecode_cache_enabled, + bool, true +) + // IMPORTANT: Keep this in condition in sync with all.js. The value // of MOZILLA_OFFICIAL is different between full and artifact builds, so without // it being specified there, dump is disabled in artifact builds (see Bug 1490412). diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js index cd62600b0071..95cea8e0aa90 100644 --- a/modules/libpref/init/all.js +++ b/modules/libpref/init/all.js @@ -232,12 +232,6 @@ pref("dom.inputevent.inputtype.enabled", true); // Whether the WebMIDI API is enabled pref("dom.webmidi.enabled", false); -// Whether to enable the JavaScript start-up cache. This causes one of the first -// execution to record the bytecode of the JavaScript function used, and save it -// in the existing cache entry. On the following loads of the same script, the -// bytecode would be loaded from the cache instead of being generated once more. -pref("dom.script_loader.bytecode_cache.enabled", true); - // Ignore the heuristics of the bytecode cache, and always record on the first // visit. (used for testing purposes).