mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-20 16:55:40 +00:00
Bug 1486556 - Avoid unlocking the helper thread state lock after looking for tasks to perform, r=jandem.
--HG-- extra : rebase_source : 1e5d20a7fbda4b982a83615fe52f2981ea8e2a80
This commit is contained in:
parent
b6e6c95bc0
commit
8b21da2df9
@ -2423,6 +2423,23 @@ HelperThread::threadLoop()
|
||||
while (!terminate) {
|
||||
MOZ_ASSERT(idle());
|
||||
|
||||
if (mozilla::recordreplay::IsRecordingOrReplaying()) {
|
||||
// Unlock the helper thread state lock before potentially
|
||||
// blocking while the main thread waits for all threads to
|
||||
// become idle. Otherwise we would need to see if we need to
|
||||
// block at every point where a helper thread acquires the
|
||||
// helper thread state lock.
|
||||
{
|
||||
AutoUnlockHelperThreadState unlock(lock);
|
||||
mozilla::recordreplay::MaybeWaitForCheckpointSave();
|
||||
}
|
||||
// Now that we are holding the helper thread state lock again,
|
||||
// notify the record/replay system that we might block soon.
|
||||
// The helper thread state lock may not be released until the
|
||||
// block occurs.
|
||||
mozilla::recordreplay::NotifyUnrecordedWait(WakeupAll);
|
||||
}
|
||||
|
||||
// The selectors may depend on the HelperThreadState not changing
|
||||
// between task selection and task execution, in particular, on new
|
||||
// tasks not being added (because of the lifo structure of the work
|
||||
@ -2432,19 +2449,6 @@ HelperThread::threadLoop()
|
||||
const TaskSpec* task = findHighestPriorityTask(lock);
|
||||
if (!task) {
|
||||
AUTO_PROFILER_LABEL("HelperThread::threadLoop::wait", IDLE);
|
||||
if (mozilla::recordreplay::IsRecordingOrReplaying()) {
|
||||
// Unlock the helper thread state lock before potentially
|
||||
// blocking while the main thread waits for all threads to
|
||||
// become idle. Otherwise we would need to see if we need to
|
||||
// block at every point where a helper thread acquires the
|
||||
// helper thread state lock.
|
||||
{
|
||||
AutoUnlockHelperThreadState unlock(lock);
|
||||
mozilla::recordreplay::MaybeWaitForCheckpointSave();
|
||||
}
|
||||
mozilla::recordreplay::NotifyUnrecordedWait(WakeupAll);
|
||||
}
|
||||
|
||||
HelperThreadState().wait(lock, GlobalHelperThreadState::PRODUCER);
|
||||
continue;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user