Index: src/heap/spaces.cc |
diff --git a/src/heap/spaces.cc b/src/heap/spaces.cc |
index abf344e79f5316332540c8773b78b3979ffe94db..95d5687a8fa4010fa6523c04d0e34018cc396639 100644 |
--- a/src/heap/spaces.cc |
+++ b/src/heap/spaces.cc |
@@ -4,6 +4,8 @@ |
#include "src/heap/spaces.h" |
+#include <utility> |
+ |
#include "src/base/bits.h" |
#include "src/base/platform/platform.h" |
#include "src/base/platform/semaphore.h" |
@@ -348,6 +350,7 @@ class MemoryAllocator::Unmapper::UnmapFreeMemoryTask : public v8::Task { |
}; |
void MemoryAllocator::Unmapper::FreeQueuedChunks() { |
+ ReconsiderDelayedChunks(); |
if (FLAG_concurrent_sweeping) { |
V8::GetCurrentPlatform()->CallOnBackgroundThread( |
new UnmapFreeMemoryTask(this), v8::Platform::kShortRunningTask); |
@@ -381,6 +384,24 @@ void MemoryAllocator::Unmapper::PerformFreeMemoryOnQueuedChunks() { |
} |
} |
+void MemoryAllocator::Unmapper::ReconsiderDelayedChunks() { |
+ std::list<MemoryChunk*> delayed_chunks(std::move(delayed_regular_chunks_)); |
+ // Move constructed, so the permanent list should be empty. |
+ DCHECK(delayed_regular_chunks_.empty()); |
+ for (auto it = delayed_chunks.begin(); it != delayed_chunks.end(); ++it) { |
+ AddMemoryChunkSafe<kRegular>(*it); |
+ } |
+} |
+ |
+bool MemoryAllocator::CanFreeMemoryChunk(MemoryChunk* chunk) { |
+ MarkCompactCollector* mc = isolate_->heap()->mark_compact_collector(); |
+ // We cannot free memory chunks in new space while the sweeper is running |
+ // since a sweeper thread might be stuck right before trying to lock the |
+ // corresponding page. |
+ return !chunk->InNewSpace() || (mc == nullptr) || |
+ mc->sweeper().IsSweepingCompleted(); |
+} |
+ |
bool MemoryAllocator::CommitMemory(Address base, size_t size, |
Executability executable) { |
if (!base::VirtualMemory::CommitRegion(base, size, |