Backed out 1 changesets (bug 1776205) for causing bug 1780426, a=backout

Backed out changeset 84c72c2fbfd6 (bug 1776205)
This commit is contained in:
Dianna Smith 2022-07-26 14:34:59 -04:00
Родитель 27fbc1c20a
Коммит 54494382c7
2 изменённых файлов: 16 добавлений и 55 удалений

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

@ -1679,6 +1679,20 @@ nsresult ScriptLoader::AttemptAsyncScriptCompile(ScriptLoadRequest* aRequest,
} else {
MOZ_ASSERT(aRequest->IsTextSource());
if (ShouldApplyDelazifyStrategy(aRequest)) {
ApplyDelazifyStrategy(&options);
mTotalFullParseSize +=
aRequest->ScriptTextLength() > 0
? static_cast<uint32_t>(aRequest->ScriptTextLength())
: 0;
LOG(
("ScriptLoadRequest (%p): non-on-demand-only Parsing Enabled for "
"url=%s mTotalFullParseSize=%u",
aRequest, aRequest->mURI->GetSpecOrDefault().get(),
mTotalFullParseSize));
}
MaybeSourceText maybeSource;
nsresult rv = aRequest->GetScriptSource(cx, &maybeSource);
NS_ENSURE_SUCCESS(rv, rv);
@ -2006,24 +2020,6 @@ nsresult ScriptLoader::FillCompileOptionsForRequest(
aOptions->allocateInstantiationStorage = true;
if (aOptions->forceFullParse()) {
// If code coverage is enabled, full-parsing is non revertable and asserts
// if any attempt to do so is made. Thus we should skip attempts to apply a
// different delazification strategy.
} else if (ShouldApplyDelazifyStrategy(aRequest)) {
ApplyDelazifyStrategy(aRequest, aOptions);
mTotalFullParseSize +=
aRequest->ScriptTextLength() > 0
? static_cast<uint32_t>(aRequest->ScriptTextLength())
: 0;
} else {
// If we cannot apply the delazification strategy set in the preference, due
// to failure of the preconditions, then we default to the strategy which
// minimize the memory impact at runtime.
aOptions->setEagerDelazificationStrategy(
JS::DelazificationOption::OnDemandOnly);
}
return NS_OK;
}
@ -3258,26 +3254,6 @@ static bool IsInternalURIScheme(nsIURI* uri) {
bool ScriptLoader::ShouldApplyDelazifyStrategy(ScriptLoadRequest* aRequest) {
// Full parse everything if negative.
if (!aRequest->IsTextSource()) {
// Delazification strategy is only used while processing source input, as
// the bytecode cache already contains delazified functions.
return false;
}
if (aRequest->IsModuleRequest()) {
// Module do not yet support concurrent off-thread delazification.
// (see Bug 1760334)
return false;
}
auto logEnabled = MakeScopeExit([&] {
LOG(
("ScriptLoadRequest (%p): non-on-demand-only Parsing Enabled for "
"url=%s mTotalFullParseSize=%u",
aRequest, aRequest->mURI->GetSpecOrDefault().get(),
mTotalFullParseSize));
});
if (StaticPrefs::dom_script_loader_delazification_max_size() < 0) {
return true;
}
@ -3285,7 +3261,6 @@ bool ScriptLoader::ShouldApplyDelazifyStrategy(ScriptLoadRequest* aRequest) {
// Be conservative on machines with 2GB or less of memory.
if (PhysicalSizeOfMemoryInGB() <=
StaticPrefs::dom_script_loader_delazification_min_mem()) {
logEnabled.release();
return false;
}
@ -3300,7 +3275,6 @@ bool ScriptLoader::ShouldApplyDelazifyStrategy(ScriptLoadRequest* aRequest) {
return true;
}
logEnabled.release();
if (LOG_ENABLED()) {
nsCString url = aRequest->mURI->GetSpecOrDefault();
LOG(
@ -3312,8 +3286,7 @@ bool ScriptLoader::ShouldApplyDelazifyStrategy(ScriptLoadRequest* aRequest) {
return false;
}
void ScriptLoader::ApplyDelazifyStrategy(ScriptLoadRequest* aRequest,
JS::CompileOptions* aOptions) {
void ScriptLoader::ApplyDelazifyStrategy(JS::CompileOptions* aOptions) {
JS::DelazificationOption strategy =
JS::DelazificationOption::ParseEverythingEagerly;
uint32_t strategyIndex =
@ -3342,17 +3315,6 @@ void ScriptLoader::ApplyDelazifyStrategy(ScriptLoadRequest* aRequest,
strategy = JS::DelazificationOption(uint8_t(strategyIndex));
}
// When using inline script, we want to minimize time spent parsing before
// running the script and thus forbid choosing the eager delazification
// strategy. It might still be selected by others means such as through code
// coverage.
if (aRequest->HasScriptLoadContext() &&
aRequest->GetScriptLoadContext()->mIsInline) {
if (strategy == JS::DelazificationOption::ParseEverythingEagerly) {
strategy = JS::DelazificationOption::OnDemandOnly;
}
}
aOptions->setEagerDelazificationStrategy(strategy);
}

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

@ -655,8 +655,7 @@ class ScriptLoader final : public JS::loader::ScriptLoaderInterface {
bool MaybeRemovedDeferRequests();
bool ShouldApplyDelazifyStrategy(ScriptLoadRequest* aRequest);
void ApplyDelazifyStrategy(ScriptLoadRequest* aRequest,
JS::CompileOptions* aOptions);
void ApplyDelazifyStrategy(JS::CompileOptions* aOptions);
bool ShouldCompileOffThread(ScriptLoadRequest* aRequest);