Index: src/heap/spaces.cc |
diff --git a/src/heap/spaces.cc b/src/heap/spaces.cc |
index 1b7a189539caea07b66e15e7d11b9e7908fbfbfd..97b85d42986f1df224e6396447da06f2dd9d5dda 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, |