Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(365)

Unified Diff: src/heap/spaces.cc

Issue 2255153002: Reland "[heap] Don't unmap new space pages while sweeping is active" (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Bring back newspace barrier Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/heap/spaces.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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,
« no previous file with comments | « src/heap/spaces.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698