Backed out 2 changesets (bug 1861848) for causing Linux asan J1 exceptions CLOSED TREE

Backed out changeset 69a9a6852a6b (bug 1861848)
Backed out changeset 1496b731cc40 (bug 1861848)
This commit is contained in:
Norisz Fay 2023-11-03 22:19:17 +02:00
parent 5dbae0b525
commit c24a942776
5 changed files with 24 additions and 37 deletions

View File

@ -8,7 +8,6 @@
#include "mozilla/StaticPrefs_javascript.h"
#include "mozilla/CycleCollectedJSRuntime.h"
#include "mozilla/ProfilerMarkers.h"
#include "mozilla/dom/ContentChild.h"
#include "mozilla/dom/ScriptSettings.h"
#include "mozilla/PerfStats.h"
#include "nsRefreshDriver.h"
@ -467,17 +466,14 @@ RefPtr<CCGCScheduler::MayGCPromise> CCGCScheduler::MayGCNow(
case JS::GCReason::USER_INACTIVE:
case JS::GCReason::FULL_GC_TIMER:
case JS::GCReason::CC_FINISHED: {
if (dom::ContentChild::GetSingleton() &&
dom::ContentChild::GetSingleton()->GetProcessPriority() <
hal::ProcessPriority::PROCESS_PRIORITY_FOREGROUND) {
if (XRE_IsContentProcess()) {
IdleSchedulerChild* child =
IdleSchedulerChild::GetMainThreadIdleScheduler();
if (child) {
return child->MayGCNow();
}
}
// Foreground content processes and the parent process don't ask
// IdleSchedulerParent whether GC can be run.
// The parent process doesn't ask IdleSchedulerParent if it can GC.
break;
}
default:

View File

@ -119,8 +119,7 @@ function checkAllCompleted(events, expectTabsCompleted) {
}
}
async function setupTabsAndOneForForeground(num_tabs) {
++num_tabs;
async function setupTabs(num_tabs) {
var pids = [];
const parent_pid = getProcessID();
@ -152,12 +151,6 @@ async function setupTabsAndOneForForeground(num_tabs) {
pids.push(tab_pid);
}
// Since calling openNewForegroundTab several times in a row doesn't update
// process priorities correctly, we need to explicitly switch tabs.
for (let tab of tabs) {
await BrowserTestUtils.switchTab(gBrowser, tab);
}
return tabs;
}
@ -179,11 +172,6 @@ function startNextCollection(
SpecialPowers.Cu.getJSTestingFunctions().finishgc();
});
if (tab.selected) {
// One isn't expected to use the return value with foreground tab!
return {};
}
var waitBegin = SpecialPowers.spawn(browser, [], waitForGCBegin);
var waitEnd = SpecialPowers.spawn(browser, [], waitForGCEnd);
waits.push({ promise: waitBegin, tab: tab_num, state: "begin" });
@ -201,7 +189,7 @@ add_task(async function gcOneAtATime() {
});
const num_tabs = 12;
var tabs = await setupTabsAndOneForForeground(num_tabs);
var tabs = await setupTabs(num_tabs);
info("Tabs ready, Asking for GCs");
var waits = [];
@ -232,7 +220,7 @@ add_task(async function gcAbort() {
});
const num_tabs = 2;
var tabs = await setupTabsAndOneForForeground(num_tabs);
var tabs = await setupTabs(num_tabs);
info("Tabs ready, Asking for GCs");
var waits = [];
@ -275,7 +263,7 @@ add_task(async function gcJSInitiatedDuring() {
});
const num_tabs = 3;
var tabs = await setupTabsAndOneForForeground(num_tabs);
var tabs = await setupTabs(num_tabs);
info("Tabs ready, Asking for GCs");
var waits = [];
@ -332,7 +320,7 @@ add_task(async function gcJSInitiatedBefore() {
});
const num_tabs = 8;
var tabs = await setupTabsAndOneForForeground(num_tabs);
var tabs = await setupTabs(num_tabs);
info("Tabs ready");
var waits = [];

View File

@ -8,9 +8,9 @@
#include "mozilla/IdlePeriodState.h"
#include "mozilla/StaticPrefs_idle_period.h"
#include "mozilla/ipc/IdleSchedulerChild.h"
#include "mozilla/dom/ContentChild.h"
#include "nsIIdlePeriod.h"
#include "nsThreadManager.h"
#include "nsThreadUtils.h"
#include "nsXPCOM.h"
#include "nsXULAppAPI.h"
@ -150,9 +150,6 @@ TimeStamp IdlePeriodState::GetIdleToken(TimeStamp aLocalIdlePeriodHint,
"Why are we touching idle state off the main thread?");
if (!ShouldGetIdleToken()) {
// If the process was in background, it may have an idle token, but it can
// be cleared now.
ClearIdleToken();
return aLocalIdlePeriodHint;
}
@ -173,12 +170,15 @@ void IdlePeriodState::RequestIdleToken(TimeStamp aLocalIdlePeriodHint) {
"Why are we touching idle state off the main thread?");
MOZ_ASSERT(!mActive);
if (!mIdleScheduler && ShouldGetIdleToken()) {
// For now cross-process idle scheduler is supported only on the main
// threads of the child processes.
mIdleScheduler = ipc::IdleSchedulerChild::GetMainThreadIdleScheduler();
if (mIdleScheduler) {
mIdleScheduler->Init(this);
if (!mIdleSchedulerInitialized) {
mIdleSchedulerInitialized = true;
if (ShouldGetIdleToken()) {
// For now cross-process idle scheduler is supported only on the main
// threads of the child processes.
mIdleScheduler = ipc::IdleSchedulerChild::GetMainThreadIdleScheduler();
if (mIdleScheduler) {
mIdleScheduler->Init(this);
}
}
}
@ -250,8 +250,6 @@ void IdlePeriodState::ClearIdleToken() {
bool IdlePeriodState::ShouldGetIdleToken() {
return StaticPrefs::idle_period_cross_process_scheduling() &&
dom::ContentChild::GetSingleton() &&
dom::ContentChild::GetSingleton()->GetProcessPriority() <
hal::ProcessPriority::PROCESS_PRIORITY_FOREGROUND;
XRE_IsContentProcess();
}
} // namespace mozilla

View File

@ -186,6 +186,11 @@ class IdlePeriodState {
// not holding any locks, but may do the latter while holding locks.
TimeStamp mCachedIdleDeadline;
// mIdleSchedulerInitialized is true if our mIdleScheduler has been
// initialized. It may be null even after initialiazation, in various
// situations.
bool mIdleSchedulerInitialized = false;
// mActive is true when the PrioritizedEventQueue or TaskController we are
// associated with is running tasks.
bool mActive = true;

View File

@ -82,7 +82,6 @@ EXPORTS.mozilla += [
]
SOURCES += [
"IdlePeriodState.cpp",
"IdleTaskRunner.cpp",
"ThreadDelay.cpp",
]
@ -93,6 +92,7 @@ UNIFIED_SOURCES += [
"CPUUsageWatcher.cpp",
"DelayedRunnable.cpp",
"EventQueue.cpp",
"IdlePeriodState.cpp",
"InputTaskManager.cpp",
"LazyIdleThread.cpp",
"MainThreadIdlePeriod.cpp",