| Index: src/spaces.cc
|
| diff --git a/src/spaces.cc b/src/spaces.cc
|
| index 12613c7cb0fc4898d9a5ca172deda517d56a2922..d431407d84a9c69e0c690de9465c1a029a5be0f6 100644
|
| --- a/src/spaces.cc
|
| +++ b/src/spaces.cc
|
| @@ -2585,8 +2585,20 @@ HeapObject* PagedSpace::WaitForSweeperThreadsAndRetryAllocation(
|
| int size_in_bytes) {
|
| MarkCompactCollector* collector = heap()->mark_compact_collector();
|
|
|
| - // If sweeper threads are still running, wait for them.
|
| if (collector->IsConcurrentSweepingInProgress(this)) {
|
| + // If sweeping is still in progress try to sweep pages on the main thread.
|
| + int free_chunk =
|
| + collector->SweepInParallel<MarkCompactCollector::SWEEP_ON_MAIN_THREAD>(
|
| + this, size_in_bytes);
|
| + if (free_chunk >= size_in_bytes) {
|
| + HeapObject* object = free_list_.Allocate(size_in_bytes);
|
| + // We should be able to allocate an object here since we just freed that
|
| + // much memory.
|
| + ASSERT(object != NULL);
|
| + if (object != NULL) return object;
|
| + }
|
| +
|
| + // Wait for the sweeper threads here and complete the sweeping phase.
|
| collector->WaitUntilSweepingCompleted();
|
|
|
| // After waiting for the sweeper threads, there may be new free-list
|
|
|