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

Unified Diff: src/heap/spaces.h

Issue 1244353002: Use a lock in pages to synchronize sweeper threads to allow others to wait on concurrently swept pa… (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 5 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/mark-compact.cc ('k') | src/heap/spaces.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap/spaces.h
diff --git a/src/heap/spaces.h b/src/heap/spaces.h
index 3461de3ef009f18d9549a8de8f18ce831ba2f572..f592796ec59d499f1d76434da72aec795277b8d5 100644
--- a/src/heap/spaces.h
+++ b/src/heap/spaces.h
@@ -452,10 +452,17 @@ class MemoryChunk {
base::Release_Store(&parallel_sweeping_, state);
}
- bool TryParallelSweeping() {
- return base::Acquire_CompareAndSwap(&parallel_sweeping_, SWEEPING_PENDING,
- SWEEPING_IN_PROGRESS) ==
- SWEEPING_PENDING;
+ bool TryLock() { return mutex_->TryLock(); }
+
+ base::Mutex* mutex() { return mutex_; }
+
+ // WaitUntilSweepingCompleted only works when concurrent sweeping is in
+ // progress. In particular, when we know that right before this call a
+ // sweeper thread was sweeping this page.
+ void WaitUntilSweepingCompleted() {
+ mutex_->Lock();
+ mutex_->Unlock();
+ DCHECK(SweepingCompleted());
}
bool SweepingCompleted() { return parallel_sweeping() <= SWEEPING_FINALIZE; }
@@ -537,9 +544,15 @@ class MemoryChunk {
static const size_t kWriteBarrierCounterOffset =
kSlotsBufferOffset + kPointerSize + kPointerSize;
- static const size_t kHeaderSize =
- kWriteBarrierCounterOffset + kPointerSize + kIntSize + kIntSize +
- kPointerSize + 5 * kPointerSize + kPointerSize + kPointerSize;
+ static const size_t kHeaderSize = kWriteBarrierCounterOffset +
+ kPointerSize + // write_barrier_counter_
+ kIntSize + // progress_bar_
+ kIntSize + // high_water_mark_
+ kPointerSize + // mutex_ page lock
+ kPointerSize + // parallel_sweeping_
+ 5 * kPointerSize + // free list statistics
+ kPointerSize + // next_chunk_
+ kPointerSize; // prev_chunk_
static const int kBodyOffset =
CODE_POINTER_ALIGN(kHeaderSize + Bitmap::kSize);
@@ -675,6 +688,7 @@ class MemoryChunk {
// count highest number of bytes ever allocated on the page.
int high_water_mark_;
+ base::Mutex* mutex_;
base::AtomicWord parallel_sweeping_;
// PagedSpace free-list statistics.
« no previous file with comments | « src/heap/mark-compact.cc ('k') | src/heap/spaces.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698