Reviewers: jarin, jochen,
Description:
The sweeper thread should not write the page flags. Added a sweeping
complete
phase, where the main thread writes the given page flags.
BUG=
Please review this at https://codereview.chromium.org/163683003/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+53, -10 lines):
M src/mark-compact.h
M src/mark-compact.cc
M src/spaces.h
M src/spaces.cc
Index: src/mark-compact.cc
diff --git a/src/mark-compact.cc b/src/mark-compact.cc
index
ef1e755d8c3f9a0004420152ec4ce7415444b62b..2a06f0199d57aec135b06648ef175e5374301c9e
100644
--- a/src/mark-compact.cc
+++ b/src/mark-compact.cc
@@ -587,6 +587,7 @@ void MarkCompactCollector::WaitUntilSweepingCompleted()
{
for (int i = 0; i < isolate()->num_sweeper_threads(); i++) {
isolate()->sweeper_threads()[i]->WaitForSweeperThread();
}
+ ParallelSweepSpacesComplete();
sweeping_pending_ = false;
RefillFreeLists(heap()->paged_space(OLD_DATA_SPACE));
RefillFreeLists(heap()->paged_space(OLD_POINTER_SPACE));
@@ -3911,7 +3912,11 @@ intptr_t
MarkCompactCollector::SweepConservatively(PagedSpace* space,
(mode == MarkCompactCollector::SWEEP_SEQUENTIALLY &&
free_list == NULL));
- p->MarkSweptConservatively();
+ // When parallel sweeping is active, the page will be marked after
+ // sweeping by the main thread.
+ if (mode != MarkCompactCollector::SWEEP_IN_PARALLEL) {
+ p->MarkSweptConservatively();
+ }
intptr_t freed_bytes = 0;
size_t size = 0;
@@ -4023,7 +4028,7 @@ void MarkCompactCollector::SweepSpace(PagedSpace*
space, SweeperType sweeper) {
while (it.has_next()) {
Page* p = it.next();
- ASSERT(p->parallel_sweeping() == 0);
+ ASSERT(p->parallel_sweeping() == MemoryChunk::PARALLEL_SWEEPING_DONE);
ASSERT(!p->IsEvacuationCandidate());
// Clear sweeping flags indicating that marking bits are still intact.
@@ -4096,7 +4101,7 @@ void MarkCompactCollector::SweepSpace(PagedSpace*
space, SweeperType sweeper) {
PrintF("Sweeping 0x%" V8PRIxPTR " conservatively in
parallel.\n",
reinterpret_cast<intptr_t>(p));
}
- p->set_parallel_sweeping(1);
+ p->set_parallel_sweeping(MemoryChunk::PARALLEL_SWEEPING_PENDING);
space->IncreaseUnsweptFreeBytes(p);
}
break;
@@ -4188,6 +4193,24 @@ void MarkCompactCollector::SweepSpaces() {
}
+void MarkCompactCollector::ParallelSweepSpaceComplete(PagedSpace* space) {
+ PageIterator it(space);
+ while (it.has_next()) {
+ Page* p = it.next();
+ if (p->parallel_sweeping() == MemoryChunk::PARALLEL_SWEEPING_COMPLETE)
{
+ p->set_parallel_sweeping(MemoryChunk::PARALLEL_SWEEPING_DONE);
+ p->MarkSweptConservatively();
+ }
+ }
+}
+
+
+void MarkCompactCollector::ParallelSweepSpacesComplete() {
+ ParallelSweepSpaceComplete(heap()->old_pointer_space());
+ ParallelSweepSpaceComplete(heap()->old_data_space());
+}
+
+
void MarkCompactCollector::EnableCodeFlushing(bool enable) {
#ifdef ENABLE_DEBUGGER_SUPPORT
if (isolate()->debug()->IsLoaded() ||
Index: src/mark-compact.h
diff --git a/src/mark-compact.h b/src/mark-compact.h
index
0773d0266683eb712f101a8f1bb026f3ca8d838a..f0d4aca30c038cec73034721c98f1c40f3c38806
100644
--- a/src/mark-compact.h
+++ b/src/mark-compact.h
@@ -940,6 +940,12 @@ class MarkCompactCollector {
void SweepSpace(PagedSpace* space, SweeperType sweeper);
+ // Finalizes the parallel sweeping phase. Marks all the pages that were
+ // swept in parallel.
+ void ParallelSweepSpacesComplete();
+
+ void ParallelSweepSpaceComplete(PagedSpace* space);
+
#ifdef DEBUG
friend class MarkObjectVisitor;
static void VisitObject(HeapObject* obj);
Index: src/spaces.cc
diff --git a/src/spaces.cc b/src/spaces.cc
index
a80341bd7fc6baa7750e76c89528ba6cbbeb29fe..9e219f833735a06e2ae088081a1004a4d9dc6592
100644
--- a/src/spaces.cc
+++ b/src/spaces.cc
@@ -483,7 +483,7 @@ MemoryChunk* MemoryChunk::Initialize(Heap* heap,
chunk->write_barrier_counter_ = kWriteBarrierCounterGranularity;
chunk->progress_bar_ = 0;
chunk->high_water_mark_ = static_cast<int>(area_start - base);
- chunk->parallel_sweeping_ = 0;
+ chunk->set_parallel_sweeping(PARALLEL_SWEEPING_DONE);
chunk->available_in_small_free_list_ = 0;
chunk->available_in_medium_free_list_ = 0;
chunk->available_in_large_free_list_ = 0;
Index: src/spaces.h
diff --git a/src/spaces.h b/src/spaces.h
index
9d47f81ac63dbbf65d357769c02f6307bf6ff15f..f152a6431189a5fec3353a1628aca33555d4414b
100644
--- a/src/spaces.h
+++ b/src/spaces.h
@@ -457,16 +457,30 @@ class MemoryChunk {
// Return all current flags.
intptr_t GetFlags() { return flags_; }
- intptr_t parallel_sweeping() const {
- return parallel_sweeping_;
+
+ // PARALLEL_SWEEPING_PENDING - This page is ready for parallel sweeping.
+ // PARALLEL_SWEEPING_COMPLETE - This page was swept by a sweeper thread.
+ // PARALLEL_SWEEPING_DONE - The page state when sweeping is complete or
+ // sweeping must not be performed on that page.
+ enum ParallelSweepingState {
+ PARALLEL_SWEEPING_DONE,
+ PARALLEL_SWEEPING_COMPLETE,
+ PARALLEL_SWEEPING_PENDING
+ };
+
+ ParallelSweepingState parallel_sweeping() {
+ return static_cast<ParallelSweepingState>(parallel_sweeping_);
}
- void set_parallel_sweeping(intptr_t state) {
- parallel_sweeping_ = state;
+ void set_parallel_sweeping(ParallelSweepingState state) {
+ NoBarrier_Store(¶llel_sweeping_, state);
}
bool TryParallelSweeping() {
- return NoBarrier_CompareAndSwap(¶llel_sweeping_, 1, 0) == 1;
+ return NoBarrier_CompareAndSwap(¶llel_sweeping_,
+ PARALLEL_SWEEPING_PENDING,
+ PARALLEL_SWEEPING_COMPLETE) ==
+ PARALLEL_SWEEPING_PENDING;
}
// Manage live byte count (count of bytes known to be live,
@@ -702,7 +716,7 @@ class MemoryChunk {
// count highest number of bytes ever allocated on the page.
int high_water_mark_;
- intptr_t parallel_sweeping_;
+ AtomicWord parallel_sweeping_;
// PagedSpace free-list statistics.
intptr_t available_in_small_free_list_;
--
--
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/groups/opt_out.