Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(398)

Unified Diff: src/heap/page-parallel-job.h

Issue 1976133002: Check number of finished tasks in PageParallelJob. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap/page-parallel-job.h
diff --git a/src/heap/page-parallel-job.h b/src/heap/page-parallel-job.h
index 0bb1ed27ad8bf859b2c8a86eebcf7c8209953c44..e78e0e2677a60d5bf3d2953c19a8bff575e4b7d4 100644
--- a/src/heap/page-parallel-job.h
+++ b/src/heap/page-parallel-job.h
@@ -39,7 +39,8 @@ class PageParallelJob {
items_(nullptr),
num_items_(0),
num_tasks_(0),
- pending_tasks_(new base::Semaphore(0)) {}
+ pending_tasks_(new base::Semaphore(0)),
+ finished_tasks_(new base::AtomicNumber<int>(0)) {}
~PageParallelJob() {
Item* item = items_;
@@ -49,6 +50,7 @@ class PageParallelJob {
item = next;
}
delete pending_tasks_;
+ delete finished_tasks_;
}
void AddPage(MemoryChunk* chunk, typename JobTraits::PerPageData data) {
@@ -83,7 +85,7 @@ class PageParallelJob {
start_index -= num_items_;
}
Task* task = new Task(heap_, items_, num_items_, start_index,
- pending_tasks_, per_task_data_callback(i));
+ pending_tasks_, per_task_data_callback(i), this);
task_ids[i] = task->id();
if (i > 0) {
V8::GetCurrentPlatform()->CallOnBackgroundThread(
@@ -95,12 +97,18 @@ class PageParallelJob {
// Contribute on main thread.
main_task->Run();
delete main_task;
+ int aborted_tasks = 0;
// Wait for background tasks.
for (int i = 0; i < num_tasks_; i++) {
if (!cancelable_task_manager_->TryAbort(task_ids[i])) {
pending_tasks_->Wait();
+ } else {
+ ++aborted_tasks;
}
}
+ int finished_tasks = finished_tasks_->Value();
+ // TODO(ulan): Remove this check after investigation of crbug.com/609249.
+ CHECK_EQ(aborted_tasks + finished_tasks, num_tasks_);
if (JobTraits::NeedSequentialFinalization) {
Item* item = items_;
while (item != nullptr) {
@@ -112,6 +120,8 @@ class PageParallelJob {
}
}
+ void NotifyFinishedTask() { finished_tasks_->Increment(1); }
+
private:
static const int kMaxNumberOfTasks = 10;
@@ -129,14 +139,16 @@ class PageParallelJob {
class Task : public CancelableTask {
public:
Task(Heap* heap, Item* items, int num_items, int start_index,
- base::Semaphore* on_finish, typename JobTraits::PerTaskData data)
+ base::Semaphore* on_finish, typename JobTraits::PerTaskData data,
+ PageParallelJob<JobTraits>* job)
: CancelableTask(heap->isolate()),
heap_(heap),
items_(items),
num_items_(num_items),
start_index_(start_index),
on_finish_(on_finish),
- data_(data) {}
+ data_(data),
+ job_(job) {}
virtual ~Task() {}
@@ -161,6 +173,7 @@ class PageParallelJob {
current = items_;
}
}
+ job_->NotifyFinishedTask();
on_finish_->Signal("PageParallelJob::Task::RunInternal");
}
@@ -170,6 +183,7 @@ class PageParallelJob {
int start_index_;
base::Semaphore* on_finish_;
typename JobTraits::PerTaskData data_;
+ PageParallelJob<JobTraits>* job_;
DISALLOW_COPY_AND_ASSIGN(Task);
};
@@ -179,6 +193,7 @@ class PageParallelJob {
int num_items_;
int num_tasks_;
base::Semaphore* pending_tasks_;
+ base::AtomicNumber<int>* finished_tasks_;
DISALLOW_COPY_AND_ASSIGN(PageParallelJob);
};
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698