Reviewers: Michael Lippautz,
Description:
Wait for concurrent unmapping tasks in GC prologue.
BUG=chromium:525372
LOG=n
Please review this at https://codereview.chromium.org/1320893002/
Base URL: https://chromium.googlesource.com/v8/v8.git@master
Affected files (+19, -8 lines):
M src/heap/heap.h
M src/heap/heap.cc
M src/heap/mark-compact.cc
Index: src/heap/heap.cc
diff --git a/src/heap/heap.cc b/src/heap/heap.cc
index
accae68a1260ce53ba5fe2b83f996e5633b2d7ee..96d0a00c863db54de117a6652c135fea46e7cd6f
100644
--- a/src/heap/heap.cc
+++ b/src/heap/heap.cc
@@ -137,7 +137,8 @@ Heap::Heap()
current_gc_callback_flags_(GCCallbackFlags::kNoGCCallbackFlags),
external_string_table_(this),
chunks_queued_for_free_(NULL),
- pending_unmap_job_semaphore_(0),
+ concurrent_unmaping_tasks_active_(0),
+ pending_unmap_tasks_semaphore_(0),
gc_callbacks_depth_(0),
deserialization_complete_(false),
concurrent_sweeping_enabled_(false),
@@ -6524,7 +6525,7 @@ class Heap::UnmapFreeMemoryTask : public v8::Task {
// v8::Task overrides.
void Run() override {
heap_->FreeQueuedChunks(head_);
- heap_->pending_unmap_job_semaphore_.Signal();
+ heap_->pending_unmap_tasks_semaphore_.Signal();
}
Heap* heap_;
@@ -6536,8 +6537,13 @@ class Heap::UnmapFreeMemoryTask : public v8::Task {
void Heap::WaitUntilUnmappingOfFreeChunksCompleted() {
// We start an unmap job after sweeping and after compaction.
- pending_unmap_job_semaphore_.Wait();
- pending_unmap_job_semaphore_.Wait();
+ if (concurrent_unmaping_tasks_active_ > 0) {
+ // There should be two concurrent unmapping tasks running.
+ DCHECK(concurrent_unmaping_tasks_active_ == 2);
+ pending_unmap_tasks_semaphore_.Wait();
+ pending_unmap_tasks_semaphore_.Wait();
+ concurrent_unmaping_tasks_active_ = 0;
+ }
}
@@ -6574,8 +6580,9 @@ void Heap::FreeQueuedChunks() {
} else {
// If we do not have anything to unmap, we just signal the semaphore
// that we are done.
- pending_unmap_job_semaphore_.Signal();
+ pending_unmap_tasks_semaphore_.Signal();
}
+ concurrent_unmaping_tasks_active_++;
}
Index: src/heap/heap.h
diff --git a/src/heap/heap.h b/src/heap/heap.h
index
a529080a5229af5ac6e3e72db2c71b597df6f127..273ccebaa1a18bf48872fc82b4f89ef202f87a20
100644
--- a/src/heap/heap.h
+++ b/src/heap/heap.h
@@ -2376,7 +2376,9 @@ class Heap {
MemoryChunk* chunks_queued_for_free_;
- base::Semaphore pending_unmap_job_semaphore_;
+ unsigned int concurrent_unmaping_tasks_active_;
+
+ base::Semaphore pending_unmap_tasks_semaphore_;
base::Mutex relocation_mutex_;
Index: src/heap/mark-compact.cc
diff --git a/src/heap/mark-compact.cc b/src/heap/mark-compact.cc
index
738e00b09ceb6fd0a4ae804dbe3b1e27aef125c0..590f5cb60c3d1ef9f70564918c450c27ea410f46
100644
--- a/src/heap/mark-compact.cc
+++ b/src/heap/mark-compact.cc
@@ -550,8 +550,6 @@ void MarkCompactCollector::EnsureSweepingCompleted() {
pending_sweeper_jobs_semaphore_.Wait();
}
- heap()->WaitUntilUnmappingOfFreeChunksCompleted();
-
ParallelSweepSpacesComplete();
sweeping_in_progress_ = false;
RefillFreeList(heap()->paged_space(OLD_SPACE));
@@ -812,6 +810,10 @@ void MarkCompactCollector::Prepare() {
EnsureSweepingCompleted();
}
+ // If concurrent unmapping tasks are still running, we should wait for
+ // them here.
+ heap()->WaitUntilUnmappingOfFreeChunksCompleted();
+
// Clear marking bits if incremental marking is aborted.
if (was_marked_incrementally_ && heap_->ShouldAbortIncrementalMarking())
{
heap()->incremental_marking()->Stop();
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.