Commit 3f315b00 authored by Etienne Pierre-doray's avatar Etienne Pierre-doray Committed by Commit Bot

[Jobs API]: Cleanup migration of missing Jobs pieces.

- JobHandle::IsCompleted()
- JobDelegate::GetTaskId()
- worker_count passed as argument to GetMaxConcurrency().
  Jobs implementation must call the new GetMaxConcurrency(), but Jobs
  users aren't migrated yet.

Bug: chromium:1114823
Change-Id: Ie09a8847d1cb884b1e388903370e49f33fa25a64
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2374308Reviewed-by: 's avatarClemens Backes <clemensb@chromium.org>
Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Commit-Queue: Etienne Pierre-Doray <etiennep@chromium.org>
Cr-Commit-Position: refs/heads/master@{#69683}
parent 1e850705
......@@ -175,9 +175,8 @@ class JobDelegate {
* Returns a task_id unique among threads currently running this job, such
* that GetTaskId() < worker count. To achieve this, the same task_id may be
* reused by a different thread after a worker_task returns.
* TODO(etiennep): Make pure virtual once custom embedders implement it.
*/
virtual uint8_t GetTaskId() { return 0; }
virtual uint8_t GetTaskId() = 0;
};
/**
......@@ -212,9 +211,8 @@ class JobHandle {
/**
* Returns true if there's no work pending and no worker running.
* TODO(etiennep): Make pure virtual once custom embedders implement it.
*/
virtual bool IsCompleted() { return true; }
virtual bool IsCompleted() = 0;
/**
* Returns true if associated with a Job and other methods may be called.
......@@ -233,23 +231,17 @@ class JobTask {
virtual void Run(JobDelegate* delegate) = 0;
/**
* Controls the maximum number of threads calling Run() concurrently. Run() is
* only invoked if the number of threads previously running Run() was less
* than the value returned. Since GetMaxConcurrency() is a leaf function, it
* must not call back any JobHandle methods.
* Controls the maximum number of threads calling Run() concurrently, given
* the number of threads currently assigned to this job and executing Run().
* Run() is only invoked if the number of threads previously running Run() was
* less than the value returned. Since GetMaxConcurrency() is a leaf function,
* it must not call back any JobHandle methods.
*/
virtual size_t GetMaxConcurrency() const = 0;
virtual size_t GetMaxConcurrency(size_t worker_count) const = 0;
/*
* Meant to replace the version above, given the number of threads currently
* assigned to this job and executing Run(). This is useful when the result
* must include local work items not visible globaly by other workers.
* TODO(etiennep): Replace the version above by this once custom embedders are
* migrated.
*/
virtual size_t GetMaxConcurrency(size_t worker_count) const {
return GetMaxConcurrency();
}
// TODO(1114823): Clean up once all overrides are removed.
V8_DEPRECATED("Use the version that takes |worker_count|.")
virtual size_t GetMaxConcurrency() const { return 0; }
};
/**
......
......@@ -276,10 +276,6 @@ class DelayedTasksPlatform final : public Platform {
job_task_->Run(delegate);
}
size_t GetMaxConcurrency() const override {
return job_task_->GetMaxConcurrency();
}
size_t GetMaxConcurrency(size_t worker_count) const override {
return job_task_->GetMaxConcurrency(worker_count);
}
......
......@@ -401,7 +401,7 @@ class ConcurrentSweepTask final : public v8::JobTask,
is_completed_.store(true, std::memory_order_relaxed);
}
size_t GetMaxConcurrency() const final {
size_t GetMaxConcurrency(size_t /* active_worker_count */) const final {
return is_completed_.load(std::memory_order_relaxed) ? 0 : 1;
}
......
......@@ -1641,7 +1641,7 @@ class BackgroundCompileJob : public JobTask {
}
}
size_t GetMaxConcurrency() const override {
size_t GetMaxConcurrency(size_t /* worker_count */) const override {
return std::min(max_concurrency_, current_concurrency_->load());
}
......@@ -3291,7 +3291,7 @@ class CompileJSToWasmWrapperJob final : public JobTask {
}
}
size_t GetMaxConcurrency() const override {
size_t GetMaxConcurrency(size_t /* worker_count */) const override {
return std::min(max_concurrency_,
outstanding_units_.load(std::memory_order_relaxed));
}
......
......@@ -36,7 +36,7 @@ TEST(DefaultJobTest, CancelJob) {
}
}
size_t GetMaxConcurrency() const override {
size_t GetMaxConcurrency(size_t /* worker_count */) const override {
return max_concurrency.load(std::memory_order_relaxed);
}
......@@ -83,7 +83,7 @@ TEST(DefaultJobTest, JoinJobContributes) {
--max_concurrency;
}
size_t GetMaxConcurrency() const override {
size_t GetMaxConcurrency(size_t /* worker_count */) const override {
return max_concurrency.load(std::memory_order_relaxed);
}
......@@ -121,11 +121,6 @@ TEST(DefaultJobTest, WorkerCount) {
if (max_concurrency > 0) --max_concurrency;
}
size_t GetMaxConcurrency() const override {
DCHECK(false); // not called.
return 0;
}
size_t GetMaxConcurrency(size_t worker_count) const override {
return worker_count + max_concurrency.load(std::memory_order_relaxed);
}
......@@ -166,7 +161,7 @@ TEST(DefaultJobTest, JobNotifyConcurrencyIncrease) {
--max_concurrency;
}
size_t GetMaxConcurrency() const override {
size_t GetMaxConcurrency(size_t /* worker_count */) const override {
return max_concurrency.load(std::memory_order_relaxed);
}
......@@ -217,7 +212,7 @@ TEST(DefaultJobTest, FinishBeforeJoin) {
--max_concurrency;
}
size_t GetMaxConcurrency() const override {
size_t GetMaxConcurrency(size_t /* worker_count */) const override {
return max_concurrency.load(std::memory_order_relaxed);
}
......@@ -254,7 +249,9 @@ TEST(DefaultJobTest, LeakHandle) {
void Run(JobDelegate* delegate) override {}
size_t GetMaxConcurrency() const override { return 0; }
size_t GetMaxConcurrency(size_t /* worker_count */) const override {
return 0;
}
};
DefaultPlatform platform(0);
......@@ -275,7 +272,9 @@ TEST(DefaultJobTest, AcquireTaskId) {
void Run(JobDelegate* delegate) override {}
size_t GetMaxConcurrency() const override { return 0; }
size_t GetMaxConcurrency(size_t /* worker_count */) const override {
return 0;
}
};
DefaultPlatform platform(0);
......
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