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

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

Issue 1782043004: [heap] Use PageParallelJob for parallel evacuation (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 9 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 | « src/heap/mark-compact.cc ('k') | src/heap/spaces.h » ('j') | 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 28a7fe8566836e839c58c171bec76b53726f4353..1b1b60c4fc99b008a64b152ebaaf1a968c20ee26 100644
--- a/src/heap/page-parallel-job.h
+++ b/src/heap/page-parallel-job.h
@@ -57,7 +57,10 @@ class PageParallelJob {
int NumberOfPages() { return num_items_; }
- // Runs the given number of tasks in parallel and processes the previosly
+ // Returns the number of tasks that were spawned when running the job.
+ int NumberOfTasks() { return num_tasks_; }
+
+ // Runs the given number of tasks in parallel and processes the previously
// added pages. This function blocks until all tasks finish.
// The callback takes the index of a task and returns data for that task.
template <typename Callback>
@@ -69,11 +72,11 @@ class PageParallelJob {
kMaxNumberOfTasks,
static_cast<int>(
V8::GetCurrentPlatform()->NumberOfAvailableBackgroundThreads()));
- num_tasks = Max(1, Min(num_tasks, max_num_tasks));
- int items_per_task = (num_items_ + num_tasks - 1) / num_tasks;
+ num_tasks_ = Max(1, Min(num_tasks, max_num_tasks));
+ int items_per_task = (num_items_ + num_tasks_ - 1) / num_tasks_;
int start_index = 0;
Task* main_task = nullptr;
- for (int i = 0; i < num_tasks; i++, start_index += items_per_task) {
+ for (int i = 0; i < num_tasks_; i++, start_index += items_per_task) {
if (start_index >= num_items_) {
start_index -= num_items_;
}
@@ -91,7 +94,7 @@ class PageParallelJob {
main_task->Run();
delete main_task;
// Wait for background tasks.
- for (int i = 0; i < num_tasks; i++) {
+ for (int i = 0; i < num_tasks_; i++) {
if (!cancelable_task_manager_->TryAbort(task_ids[i])) {
pending_tasks_.Wait();
}
@@ -172,6 +175,7 @@ class PageParallelJob {
CancelableTaskManager* cancelable_task_manager_;
Item* items_;
int num_items_;
+ int num_tasks_;
base::Semaphore pending_tasks_;
DISALLOW_COPY_AND_ASSIGN(PageParallelJob);
};
« no previous file with comments | « src/heap/mark-compact.cc ('k') | src/heap/spaces.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698