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; ...@@ -321,6 +321,8 @@ class ThreadLocalTop;
// Mark-Compact collector // Mark-Compact collector
class MarkCompactCollector { class MarkCompactCollector {
public: public:
class Evacuator;
enum IterationMode { enum IterationMode {
kKeepMarking, kKeepMarking,
kClearMarkbits, kClearMarkbits,
...@@ -504,11 +506,9 @@ class MarkCompactCollector { ...@@ -504,11 +506,9 @@ class MarkCompactCollector {
} }
private: private:
class CompactionTask;
class EvacuateNewSpaceVisitor; class EvacuateNewSpaceVisitor;
class EvacuateOldSpaceVisitor; class EvacuateOldSpaceVisitor;
class EvacuateVisitorBase; class EvacuateVisitorBase;
class Evacuator;
class HeapObjectVisitor; class HeapObjectVisitor;
class SweeperTask; class SweeperTask;
...@@ -704,9 +704,6 @@ class MarkCompactCollector { ...@@ -704,9 +704,6 @@ class MarkCompactCollector {
// The number of parallel compaction tasks, including the main thread. // The number of parallel compaction tasks, including the main thread.
int NumberOfParallelCompactionTasks(int pages, intptr_t live_bytes); int NumberOfParallelCompactionTasks(int pages, intptr_t live_bytes);
void StartParallelCompaction(Evacuator** evacuators, int len);
void WaitUntilCompactionCompleted(Evacuator** evacuators, int len);
void EvacuateNewSpaceAndCandidates(); void EvacuateNewSpaceAndCandidates();
void UpdatePointersAfterEvacuation(); void UpdatePointersAfterEvacuation();
......
...@@ -57,7 +57,10 @@ class PageParallelJob { ...@@ -57,7 +57,10 @@ class PageParallelJob {
int NumberOfPages() { return num_items_; } 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. // added pages. This function blocks until all tasks finish.
// The callback takes the index of a task and returns data for that task. // The callback takes the index of a task and returns data for that task.
template <typename Callback> template <typename Callback>
...@@ -69,11 +72,11 @@ class PageParallelJob { ...@@ -69,11 +72,11 @@ class PageParallelJob {
kMaxNumberOfTasks, kMaxNumberOfTasks,
static_cast<int>( static_cast<int>(
V8::GetCurrentPlatform()->NumberOfAvailableBackgroundThreads())); V8::GetCurrentPlatform()->NumberOfAvailableBackgroundThreads()));
num_tasks = Max(1, Min(num_tasks, max_num_tasks)); num_tasks_ = Max(1, Min(num_tasks, max_num_tasks));
int items_per_task = (num_items_ + num_tasks - 1) / num_tasks; int items_per_task = (num_items_ + num_tasks_ - 1) / num_tasks_;
int start_index = 0; int start_index = 0;
Task* main_task = nullptr; 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_) { if (start_index >= num_items_) {
start_index -= num_items_; start_index -= num_items_;
} }
...@@ -91,7 +94,7 @@ class PageParallelJob { ...@@ -91,7 +94,7 @@ class PageParallelJob {
main_task->Run(); main_task->Run();
delete main_task; delete main_task;
// Wait for background tasks. // 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])) { if (!cancelable_task_manager_->TryAbort(task_ids[i])) {
pending_tasks_.Wait(); pending_tasks_.Wait();
} }
...@@ -172,6 +175,7 @@ class PageParallelJob { ...@@ -172,6 +175,7 @@ class PageParallelJob {
CancelableTaskManager* cancelable_task_manager_; CancelableTaskManager* cancelable_task_manager_;
Item* items_; Item* items_;
int num_items_; int num_items_;
int num_tasks_;
base::Semaphore pending_tasks_; base::Semaphore pending_tasks_;
DISALLOW_COPY_AND_ASSIGN(PageParallelJob); DISALLOW_COPY_AND_ASSIGN(PageParallelJob);
}; };
......
...@@ -485,7 +485,6 @@ MemoryChunk* MemoryChunk::Initialize(Heap* heap, Address base, size_t size, ...@@ -485,7 +485,6 @@ MemoryChunk* MemoryChunk::Initialize(Heap* heap, Address base, size_t size,
chunk->progress_bar_ = 0; chunk->progress_bar_ = 0;
chunk->high_water_mark_.SetValue(static_cast<intptr_t>(area_start - base)); chunk->high_water_mark_.SetValue(static_cast<intptr_t>(area_start - base));
chunk->concurrent_sweeping_state().SetValue(kSweepingDone); chunk->concurrent_sweeping_state().SetValue(kSweepingDone);
chunk->parallel_compaction_state().SetValue(kCompactingDone);
chunk->mutex_ = nullptr; chunk->mutex_ = nullptr;
chunk->available_in_free_list_ = 0; chunk->available_in_free_list_ = 0;
chunk->wasted_memory_ = 0; chunk->wasted_memory_ = 0;
......
...@@ -302,7 +302,6 @@ class MemoryChunk { ...@@ -302,7 +302,6 @@ class MemoryChunk {
EVACUATION_CANDIDATE, EVACUATION_CANDIDATE,
RESCAN_ON_EVACUATION, RESCAN_ON_EVACUATION,
NEVER_EVACUATE, // May contain immortal immutables. 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 // 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. // are scanned in increments and will be kept black while being scanned.
...@@ -331,19 +330,6 @@ class MemoryChunk { ...@@ -331,19 +330,6 @@ class MemoryChunk {
NUM_MEMORY_CHUNK_FLAGS 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 // |kSweepingDone|: The page state when sweeping is complete or sweeping must
// not be performed on that page. Sweeper threads that are done with their // not be performed on that page. Sweeper threads that are done with their
// work will set this value and not touch the page anymore. // work will set this value and not touch the page anymore.
...@@ -403,8 +389,7 @@ class MemoryChunk { ...@@ -403,8 +389,7 @@ class MemoryChunk {
kIntptrSize // intptr_t write_barrier_counter_ kIntptrSize // intptr_t write_barrier_counter_
+ kPointerSize // AtomicValue high_water_mark_ + kPointerSize // AtomicValue high_water_mark_
+ kPointerSize // base::Mutex* mutex_ + kPointerSize // base::Mutex* mutex_
+ kPointerSize // base::AtomicWord parallel_sweeping_ + kPointerSize // base::AtomicWord concurrent_sweeping_
+ kPointerSize // AtomicValue parallel_compaction_
+ 2 * kPointerSize // AtomicNumber free-list statistics + 2 * kPointerSize // AtomicNumber free-list statistics
+ kPointerSize // AtomicValue next_chunk_ + kPointerSize // AtomicValue next_chunk_
+ kPointerSize; // AtomicValue prev_chunk_ + kPointerSize; // AtomicValue prev_chunk_
...@@ -471,10 +456,6 @@ class MemoryChunk { ...@@ -471,10 +456,6 @@ class MemoryChunk {
return concurrent_sweeping_; return concurrent_sweeping_;
} }
AtomicValue<ParallelCompactingState>& parallel_compaction_state() {
return parallel_compaction_;
}
// Manage live byte count, i.e., count of bytes in black objects. // Manage live byte count, i.e., count of bytes in black objects.
inline void ResetLiveBytes(); inline void ResetLiveBytes();
inline void IncrementLiveBytes(int by); inline void IncrementLiveBytes(int by);
...@@ -701,7 +682,6 @@ class MemoryChunk { ...@@ -701,7 +682,6 @@ class MemoryChunk {
base::Mutex* mutex_; base::Mutex* mutex_;
AtomicValue<ConcurrentSweepingState> concurrent_sweeping_; AtomicValue<ConcurrentSweepingState> concurrent_sweeping_;
AtomicValue<ParallelCompactingState> parallel_compaction_;
// PagedSpace free-list statistics. // PagedSpace free-list statistics.
AtomicNumber<intptr_t> available_in_free_list_; 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