| Index: src/heap.cc
|
| diff --git a/src/heap.cc b/src/heap.cc
|
| index 401f4f7948adc09cb845390ef7f37036fa179aee..e7a9fdc8ce9cfe8eb8c7cd2f2aac19702f7693fb 100644
|
| --- a/src/heap.cc
|
| +++ b/src/heap.cc
|
| @@ -563,6 +563,54 @@ void Heap::CollectAllGarbage(int flags, const char* gc_reason) {
|
| }
|
|
|
|
|
| +void Heap::StartParallelSweeping(SweeperType sweeper_type) {
|
| + SweeperThread::set_sweeping_pending(true);
|
| + for (int i = 0; i < FLAG_sweeper_threads; i++) {
|
| + isolate()->sweeper_threads()[i]->StartSweeping(sweeper_type);
|
| + }
|
| +}
|
| +
|
| +
|
| +void Heap::WaitUntilParallelSweepingCompleted() {
|
| + for (int i = 0; i < FLAG_sweeper_threads; i++) {
|
| + isolate()->sweeper_threads()[i]->WaitForSweeperThread();
|
| + }
|
| + SweeperThread::set_sweeping_pending(false);
|
| + FinalizeParallelSweeping();
|
| +}
|
| +
|
| +
|
| +void Heap::StealMemoryFromSweeperThreads(PagedSpace* space) {
|
| + for (int i = 0; i < FLAG_sweeper_threads; i++) {
|
| + isolate()->sweeper_threads()[i]->StealMemory(space);
|
| + }
|
| +}
|
| +
|
| +
|
| +void Heap::FinalizeParallelSweeping() {
|
| + StealMemoryFromSweeperThreads(paged_space(OLD_DATA_SPACE));
|
| + StealMemoryFromSweeperThreads(paged_space(OLD_POINTER_SPACE));
|
| + FreeQueuedChunks();
|
| +}
|
| +
|
| +
|
| +bool Heap::IsConcurrentSweepingPending() {
|
| + return SweeperThread::sweeping_pending();
|
| +}
|
| +
|
| +
|
| +bool Heap::IsConcurrentSweepingActivated() {
|
| + return isolate()->sweeper_threads() != NULL &&
|
| + FLAG_concurrent_sweeping;
|
| +}
|
| +
|
| +
|
| +bool Heap::AreSweepingThreadsActivated() {
|
| + return isolate()->sweeper_threads() != NULL &&
|
| + (FLAG_concurrent_sweeping || FLAG_parallel_sweeping);
|
| +}
|
| +
|
| +
|
| void Heap::CollectAllAvailableGarbage(const char* gc_reason) {
|
| // Since we are ignoring the return value, the exact choice of space does
|
| // not matter, so long as we do not specify NEW_SPACE, which would not
|
| @@ -1273,7 +1321,12 @@ void Heap::Scavenge() {
|
|
|
| incremental_marking()->PrepareForScavenge();
|
|
|
| - AdvanceSweepers(static_cast<int>(new_space_.Size()));
|
| + if (AreSweepingThreadsActivated()) {
|
| + StealMemoryFromSweeperThreads(paged_space(OLD_DATA_SPACE));
|
| + StealMemoryFromSweeperThreads(paged_space(OLD_POINTER_SPACE));
|
| + } else {
|
| + AdvanceSweepers(static_cast<int>(new_space_.Size()));
|
| + }
|
|
|
| // Flip the semispaces. After flipping, to space is empty, from space has
|
| // live objects.
|
|
|