[Jobs]: Fix task id lifetime.

Delegate kept task id around for longer than the worker is considered
active, thus breaking the task_id < num_worker garantee. The fix is to
adjust the delegate lifetime.

Change-Id: I9aabb1286d507c09bfe9be4fd4f810f232d6e6b9
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2437005
Commit-Queue: Etienne Pierre-Doray <etiennep@chromium.org>
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#70207}
This commit is contained in:
Etienne Pierre-doray 2020-09-29 12:03:14 -04:00 committed by Commit Bot
parent 805f19319e
commit 6d776e5792

View File

@ -127,9 +127,11 @@ class DefaultJobWorker : public Task {
void Run() override {
auto shared_state = state_.lock();
if (!shared_state) return;
DefaultJobState::JobDelegate delegate(shared_state.get());
if (!shared_state->CanRunFirstTask()) return;
do {
// Scope of |delegate| must not outlive DidRunTask() so that associated
// state is freed before the worker becomes inactive.
DefaultJobState::JobDelegate delegate(shared_state.get());
job_task_->Run(&delegate);
} while (shared_state->DidRunTask());
}