Reviewers: Michael Lippautz,
Description:
Add basic support for parallel compaction and flag.
BUG=524425
LOG=n
Please review this at https://codereview.chromium.org/1314903002/
Base URL: https://chromium.googlesource.com/v8/v8.git@master
Affected files (+44, -1 lines):
M src/flag-definitions.h
M src/heap/mark-compact.h
M src/heap/mark-compact.cc
Index: src/flag-definitions.h
diff --git a/src/flag-definitions.h b/src/flag-definitions.h
index
51d716e2911f6e868a61c328c69073c1161a6a5b..5e32965844a32efb2fd37c8c99c3e9d9cbaa5fd2
100644
--- a/src/flag-definitions.h
+++ b/src/flag-definitions.h
@@ -659,6 +659,7 @@ DEFINE_INT(min_progress_during_object_groups_marking,
128,
DEFINE_INT(max_object_groups_marking_rounds, 3,
"at most try this many times to over approximate the weak
closure")
DEFINE_BOOL(concurrent_sweeping, true, "use concurrent sweeping")
+DEFINE_BOOL(parallel_compaction, false, "use parallel compaction")
DEFINE_BOOL(trace_incremental_marking, false,
"trace progress of the incremental marking")
DEFINE_BOOL(track_gc_object_stats, false,
@@ -808,6 +809,7 @@ DEFINE_BOOL(predictable, false, "enable predictable
mode")
DEFINE_NEG_IMPLICATION(predictable, concurrent_recompilation)
DEFINE_NEG_IMPLICATION(predictable, concurrent_osr)
DEFINE_NEG_IMPLICATION(predictable, concurrent_sweeping)
+DEFINE_NEG_IMPLICATION(predictable, parallel_compaction)
// mark-compact.cc
DEFINE_BOOL(force_marking_deque_overflows, false,
Index: src/heap/mark-compact.cc
diff --git a/src/heap/mark-compact.cc b/src/heap/mark-compact.cc
index
4c8db42035bb8c5722fe9b2fbe73b35d87f43f54..12f911ac7617ee65212eeea6eb03c77181a0ef9c
100644
--- a/src/heap/mark-compact.cc
+++ b/src/heap/mark-compact.cc
@@ -48,6 +48,7 @@ MarkCompactCollector::MarkCompactCollector(Heap* heap)
was_marked_incrementally_(false),
sweeping_in_progress_(false),
pending_sweeper_jobs_semaphore_(0),
+ pending_compaction_jobs_semaphore_(0),
evacuation_(false),
migration_slots_buffer_(NULL),
heap_(heap),
@@ -459,6 +460,28 @@ void MarkCompactCollector::ClearMarkbits() {
}
+class MarkCompactCollector::CompactionTask : public v8::Task {
+ public:
+ explicit CompactionTask(Heap* heap) : heap_(heap) {}
+
+ virtual ~CompactionTask() {}
+
+ private:
+ // v8::Task overrides.
+ void Run() override {
+ // TODO(hpayer): EvacuatePages is not thread-safe and can just be
called by
+ // one thread concurrently.
+ heap_->mark_compact_collector()->EvacuatePages();
+ heap_->mark_compact_collector()
+ ->pending_compaction_jobs_semaphore_.Signal();
+ }
+
+ Heap* heap_;
+
+ DISALLOW_COPY_AND_ASSIGN(CompactionTask);
+};
+
+
class MarkCompactCollector::SweeperTask : public v8::Task {
public:
SweeperTask(Heap* heap, PagedSpace* space) : heap_(heap), space_(space)
{}
@@ -3289,6 +3312,12 @@ void
MarkCompactCollector::EvacuateLiveObjectsFromPage(Page* p) {
}
+void MarkCompactCollector::EvacuatePagesInParallel() {
+ V8::GetCurrentPlatform()->CallOnBackgroundThread(
+ new CompactionTask(heap()), v8::Platform::kShortRunningTask);
+}
+
+
void MarkCompactCollector::EvacuatePages() {
int npages = evacuation_candidates_.length();
int abandoned_pages = 0;
@@ -3595,7 +3624,12 @@ void
MarkCompactCollector::EvacuateNewSpaceAndCandidates() {
GCTracer::Scope gc_scope(heap()->tracer(),
GCTracer::Scope::MC_EVACUATE_PAGES);
EvacuationScope evacuation_scope(this);
- EvacuatePages();
+ if (FLAG_parallel_compaction) {
+ EvacuatePagesInParallel();
+ pending_compaction_jobs_semaphore_.Wait();
+ } else {
+ EvacuatePages();
+ }
}
// Second pass: find pointers to new space and update them.
Index: src/heap/mark-compact.h
diff --git a/src/heap/mark-compact.h b/src/heap/mark-compact.h
index
843e73d8e7dfa7d026036e70a8c80d9cd206204f..12da2d66747a939140dcdaf0816574513cd9ad03
100644
--- a/src/heap/mark-compact.h
+++ b/src/heap/mark-compact.h
@@ -668,6 +668,7 @@ class MarkCompactCollector {
void RemoveObjectSlots(Address start_slot, Address end_slot);
private:
+ class CompactionTask;
class SweeperTask;
explicit MarkCompactCollector(Heap* heap);
@@ -705,8 +706,12 @@ class MarkCompactCollector {
// True if concurrent or parallel sweeping is currently in progress.
bool sweeping_in_progress_;
+ // Synchronize sweeper threads.
base::Semaphore pending_sweeper_jobs_semaphore_;
+ // Synchronize compaction threads.
+ base::Semaphore pending_compaction_jobs_semaphore_;
+
bool evacuation_;
SlotsBufferAllocator slots_buffer_allocator_;
@@ -865,6 +870,8 @@ class MarkCompactCollector {
void EvacuatePages();
+ void EvacuatePagesInParallel();
+
void EvacuateNewSpaceAndCandidates();
void ReleaseEvacuationCandidates();
--
--
v8-dev mailing list
v8-dev@googlegroups.com
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 v8-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.