Bug 1548253 - Port pref cache variables of nsContentUtils to StaticPrefs - dom.script_loader.bytecode_cache.strategy, r=Ehsan

Differential Revision: https://phabricator.services.mozilla.com/D29525

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Andrea Marchesini 2019-05-01 21:11:48 +00:00
Родитель ff333370f8
Коммит f50233ec54
5 изменённых файлов: 22 добавлений и 27 удалений

Просмотреть файл

@ -314,7 +314,6 @@ bool nsContentUtils::sInitialized = false;
bool nsContentUtils::sBypassCSSOMOriginCheck = false;
#endif
int32_t nsContentUtils::sBytecodeCacheStrategy = 0;
nsCString* nsContentUtils::sJSBytecodeMimeType = nullptr;
nsContentUtils::UserInteractionObserver*
@ -609,9 +608,6 @@ nsresult nsContentUtils::Init() {
sBypassCSSOMOriginCheck = getenv("MOZ_BYPASS_CSSOM_ORIGIN_CHECK");
#endif
Preferences::AddIntVarCache(&sBytecodeCacheStrategy,
"dom.script_loader.bytecode_cache.strategy", 0);
nsDependentCString buildID(mozilla::PlatformBuildID());
sJSBytecodeMimeType =
new nsCString(NS_LITERAL_CSTRING("javascript/moz-bytecode-") + buildID);

Просмотреть файл

@ -3188,10 +3188,6 @@ class nsContentUtils {
*/
static bool GetUserIsInteracting();
// 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; }
// Alternate data MIME type used by the ScriptLoader to register and read
// bytecode out of the nsCacheInfoChannel.
static nsCString& JSBytecodeMimeType() { return *sJSBytecodeMimeType; }
@ -3403,7 +3399,6 @@ class nsContentUtils {
#ifndef RELEASE_OR_BETA
static bool sBypassCSSOMOriginCheck;
#endif
static int32_t sBytecodeCacheStrategy;
class UserInteractionObserver;
static UserInteractionObserver* sUserInteractionObserver;

Просмотреть файл

@ -2386,7 +2386,7 @@ bool ScriptLoader::ShouldCacheBytecode(ScriptLoadRequest* aRequest) {
// Look at the preference to know which strategy (parameters) should be used
// when the bytecode cache is enabled.
int32_t strategy = nsContentUtils::BytecodeCacheStrategy();
int32_t strategy = StaticPrefs::dom_script_loader_bytecode_cache_strategy();
// List of parameters used by the strategies.
bool hasSourceLengthMin = false;

Просмотреть файл

@ -548,6 +548,27 @@ VARCACHE_PREF(
bool, true
)
// Ignore the heuristics of the bytecode cache, and always record on the first
// visit. (used for testing purposes).
// Choose one strategy to use to decide when the bytecode should be encoded and
// saved. The following strategies are available right now:
// * -2 : (reader mode) The bytecode cache would be read, but it would never
// be saved.
// * -1 : (eager mode) The bytecode would be saved as soon as the script is
// seen for the first time, independently of the size or last access
// time.
// * 0 : (default) The bytecode would be saved in order to minimize the
// page-load time.
//
// Other values might lead to experimental strategies. For more details, have a
// look at: ScriptLoader::ShouldCacheBytecode function.
VARCACHE_PREF(
"dom.script_loader.bytecode_cache.strategy",
dom_script_loader_bytecode_cache_strategy,
int32_t, 0
)
// 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).

Просмотреть файл

@ -232,23 +232,6 @@ pref("dom.inputevent.inputtype.enabled", true);
// Whether the WebMIDI API is enabled
pref("dom.webmidi.enabled", false);
// Ignore the heuristics of the bytecode cache, and always record on the first
// visit. (used for testing purposes).
// Choose one strategy to use to decide when the bytecode should be encoded and
// saved. The following strategies are available right now:
// * -2 : (reader mode) The bytecode cache would be read, but it would never
// be saved.
// * -1 : (eager mode) The bytecode would be saved as soon as the script is
// seen for the first time, independently of the size or last access
// time.
// * 0 : (default) The bytecode would be saved in order to minimize the
// page-load time.
//
// Other values might lead to experimental strategies. For more details, have a
// look at: ScriptLoader::ShouldCacheBytecode function.
pref("dom.script_loader.bytecode_cache.strategy", 0);
#ifdef JS_BUILD_BINAST
pref("dom.script_loader.binast_encoding.enabled", false);
pref("dom.script_loader.binast_encoding.domain.restrict.list", "*.facebook.com,static.xx.fbcdn.net");