Bug 1705733 - Replace threads.empty() check with CanUseExtraThreads(). r=jonco

Differential Revision: https://phabricator.services.mozilla.com/D112532
This commit is contained in:
Yoshi Cheng-Hao Huang 2021-04-19 21:59:33 +00:00
parent 058229227c
commit c63ca4d51c

View File

@ -182,7 +182,7 @@ bool GlobalHelperThreadState::submitTask(wasm::UniqueTier2GeneratorTask task) {
static void CancelOffThreadWasmTier2GeneratorLocked(
AutoLockHelperThreadState& lock) {
if (HelperThreadState().threads(lock).empty()) {
if (!CanUseExtraThreads()) {
return;
}
@ -345,7 +345,7 @@ static bool IonCompileTaskMatches(const CompilationSelector& selector,
static void CancelOffThreadIonCompileLocked(const CompilationSelector& selector,
AutoLockHelperThreadState& lock) {
if (HelperThreadState().threads(lock).empty()) {
if (!CanUseExtraThreads()) {
return;
}
@ -422,12 +422,12 @@ void js::CancelOffThreadIonCompile(const CompilationSelector& selector) {
#ifdef DEBUG
bool js::HasOffThreadIonCompile(Realm* realm) {
AutoLockHelperThreadState lock;
if (HelperThreadState().threads(lock).empty()) {
if (!CanUseExtraThreads()) {
return false;
}
AutoLockHelperThreadState lock;
GlobalHelperThreadState::IonCompileTaskVector& worklist =
HelperThreadState().ionWorklist(lock);
for (size_t i = 0; i < worklist.length(); i++) {
@ -907,7 +907,7 @@ void MultiScriptsDecodeTask::parse(JSContext* cx) {
static void WaitForOffThreadParses(JSRuntime* rt,
AutoLockHelperThreadState& lock) {
if (HelperThreadState().threads(lock).empty()) {
if (!CanUseExtraThreads()) {
return;
}
@ -2466,12 +2466,12 @@ static void ClearCompressionTaskList(T& list, JSRuntime* runtime) {
}
void js::CancelOffThreadCompressions(JSRuntime* runtime) {
AutoLockHelperThreadState lock;
if (HelperThreadState().threads(lock).empty()) {
if (!CanUseExtraThreads()) {
return;
}
AutoLockHelperThreadState lock;
// Cancel all pending compression tasks.
ClearCompressionTaskList(HelperThreadState().compressionPendingList(lock),
runtime);
@ -2526,12 +2526,12 @@ void js::SweepPendingCompressions(AutoLockHelperThreadState& lock) {
}
void js::RunPendingSourceCompressions(JSRuntime* runtime) {
AutoLockHelperThreadState lock;
if (HelperThreadState().threads(lock).empty()) {
if (!CanUseExtraThreads()) {
return;
}
AutoLockHelperThreadState lock;
HelperThreadState().startHandlingCompressionTasks(
GlobalHelperThreadState::ScheduleCompressionTask::API, nullptr, lock);