Commit 4566531c authored by mlippautz's avatar mlippautz Committed by Commit bot

[heap] Use PageParallelJob for parallel evacuation

Move evacuation of new and old space pages to the provided framework for
parallelization.

Drive-by-fix: Remove left overs from POPULAR_PAGE flag.

BUG=chromium:524425
LOG=N

Review URL: https://codereview.chromium.org/1782043004

Cr-Commit-Position: refs/heads/master@{#34687}
parent d81c3b4a
This diff is collapsed.
......@@ -321,6 +321,8 @@ class ThreadLocalTop;
// Mark-Compact collector
class MarkCompactCollector {
public:
class Evacuator;
enum IterationMode {
kKeepMarking,
kClearMarkbits,
......@@ -504,11 +506,9 @@ class MarkCompactCollector {
}
private:
class CompactionTask;
class EvacuateNewSpaceVisitor;
class EvacuateOldSpaceVisitor;
class EvacuateVisitorBase;
class Evacuator;
class HeapObjectVisitor;
class SweeperTask;
......@@ -704,9 +704,6 @@ class MarkCompactCollector {
// The number of parallel compaction tasks, including the main thread.
int NumberOfParallelCompactionTasks(int pages, intptr_t live_bytes);
void StartParallelCompaction(Evacuator** evacuators, int len);
void WaitUntilCompactionCompleted(Evacuator** evacuators, int len);
void EvacuateNewSpaceAndCandidates();
void UpdatePointersAfterEvacuation();
......
......@@ -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);
};
......
......@@ -485,7 +485,6 @@ MemoryChunk* MemoryChunk::Initialize(Heap* heap, Address base, size_t size,
chunk->progress_bar_ = 0;
chunk->high_water_mark_.SetValue(static_cast<intptr_t>(area_start - base));
chunk->concurrent_sweeping_state().SetValue(kSweepingDone);
chunk->parallel_compaction_state().SetValue(kCompactingDone);
chunk->mutex_ = nullptr;
chunk->available_in_free_list_ = 0;
chunk->wasted_memory_ = 0;
......
......@@ -302,7 +302,6 @@ class MemoryChunk {
EVACUATION_CANDIDATE,
RESCAN_ON_EVACUATION,
NEVER_EVACUATE, // May contain immortal immutables.
POPULAR_PAGE, // Slots buffer of this page overflowed on the previous GC.
// Large objects can have a progress bar in their page header. These object
// are scanned in increments and will be kept black while being scanned.
......@@ -331,19 +330,6 @@ class MemoryChunk {
NUM_MEMORY_CHUNK_FLAGS
};
// |kCompactionDone|: Initial compaction state of a |MemoryChunk|.
// |kCompactingInProgress|: Parallel compaction is currently in progress.
// |kCompactingFinalize|: Parallel compaction is done but the chunk needs to
// be finalized.
// |kCompactingAborted|: Parallel compaction has been aborted, which should
// for now only happen in OOM scenarios.
enum ParallelCompactingState {
kCompactingDone,
kCompactingInProgress,
kCompactingFinalize,
kCompactingAborted,
};
// |kSweepingDone|: The page state when sweeping is complete or sweeping must
// not be performed on that page. Sweeper threads that are done with their
// work will set this value and not touch the page anymore.
......@@ -403,8 +389,7 @@ class MemoryChunk {
kIntptrSize // intptr_t write_barrier_counter_
+ kPointerSize // AtomicValue high_water_mark_
+ kPointerSize // base::Mutex* mutex_
+ kPointerSize // base::AtomicWord parallel_sweeping_
+ kPointerSize // AtomicValue parallel_compaction_
+ kPointerSize // base::AtomicWord concurrent_sweeping_
+ 2 * kPointerSize // AtomicNumber free-list statistics
+ kPointerSize // AtomicValue next_chunk_
+ kPointerSize; // AtomicValue prev_chunk_
......@@ -471,10 +456,6 @@ class MemoryChunk {
return concurrent_sweeping_;
}
AtomicValue<ParallelCompactingState>& parallel_compaction_state() {
return parallel_compaction_;
}
// Manage live byte count, i.e., count of bytes in black objects.
inline void ResetLiveBytes();
inline void IncrementLiveBytes(int by);
......@@ -701,7 +682,6 @@ class MemoryChunk {
base::Mutex* mutex_;
AtomicValue<ConcurrentSweepingState> concurrent_sweeping_;
AtomicValue<ParallelCompactingState> parallel_compaction_;
// PagedSpace free-list statistics.
AtomicNumber<intptr_t> available_in_free_list_;
......
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