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

Unified Diff: src/heap/mark-compact.cc

Issue 1314903002: Add basic support for parallel compaction and flag. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 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/mark-compact.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap/mark-compact.cc
diff --git a/src/heap/mark-compact.cc b/src/heap/mark-compact.cc
index 4c8db42035bb8c5722fe9b2fbe73b35d87f43f54..998ac07d1ea87d4270232ae5455bf5438e007873 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(mlippautz, 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.
« no previous file with comments | « src/heap/mark-compact.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698