Commit 2e96d321 authored by Leszek Swirski's avatar Leszek Swirski Committed by V8 LUCI CQ

[compiler-dispatcher] Fix job delete posting

Some bad rebasing meant that we were still deleting on the main thread.

As an additional simplification, remove the specific deletion queue
mutex, and just use the compiler dispatcher mutex for the deletion queue
-- this avoids risks of deadlock when both are held.

Change-Id: Ifa4ead6ee3fd814d7f013dd14a5617456afc9f7f
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3328785
Auto-Submit: Leszek Swirski <leszeks@chromium.org>
Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/main@{#78335}
parent 7f121b4f
......@@ -456,7 +456,7 @@ void LazyCompileDispatcher::DoBackgroundWork(JobDelegate* delegate) {
while (!delegate->ShouldYield()) {
Job* job = nullptr;
{
base::MutexGuard lock(&job_dispose_mutex_);
base::MutexGuard lock(&mutex_);
if (jobs_to_dispose_.empty()) break;
job = jobs_to_dispose_.back();
jobs_to_dispose_.pop_back();
......@@ -538,13 +538,8 @@ void LazyCompileDispatcher::DoIdleWork(double deadline_in_seconds) {
void LazyCompileDispatcher::DeleteJob(Job* job) {
DCHECK(job->state == Job::State::kFinalized);
#ifdef DEBUG
{
base::MutexGuard lock(&mutex_);
all_jobs_.erase(job);
}
#endif
delete job;
base::MutexGuard lock(&mutex_);
DeleteJob(job, lock);
}
void LazyCompileDispatcher::DeleteJob(Job* job, const base::MutexGuard&) {
......@@ -552,7 +547,6 @@ void LazyCompileDispatcher::DeleteJob(Job* job, const base::MutexGuard&) {
#ifdef DEBUG
all_jobs_.erase(job);
#endif
base::MutexGuard lock(&job_dispose_mutex_);
jobs_to_dispose_.push_back(job);
if (jobs_to_dispose_.size() == 1) {
num_jobs_for_background_++;
......
......@@ -220,14 +220,17 @@ class V8_EXPORT_PRIVATE LazyCompileDispatcher {
std::unordered_set<Job*> all_jobs_;
#endif
// A queue of jobs to delete on the background thread(s). Jobs in this queue
// are considered dead as far as the rest of the system is concerned, so they
// won't be pointed to by any SharedFunctionInfo and won't be in the all_jobs
// set above.
std::vector<Job*> jobs_to_dispose_;
// If not nullptr, then the main thread waits for the task processing
// this job, and blocks on the ConditionVariable main_thread_blocking_signal_.
Job* main_thread_blocking_on_job_;
base::ConditionVariable main_thread_blocking_signal_;
mutable base::Mutex job_dispose_mutex_;
std::vector<Job*> jobs_to_dispose_;
// Test support.
base::AtomicValue<bool> block_for_testing_;
base::Semaphore semaphore_for_testing_;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment