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

Unified Diff: src/heap/spaces.cc

Issue 1871423002: [heap] Refactor Sweeper (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Comments round 2 Created 4 years, 8 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-inl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap/spaces.cc
diff --git a/src/heap/spaces.cc b/src/heap/spaces.cc
index 82370f50664c9dfc9be356617aede01711ffce9f..bcbc5119eb54493dac170d00b694727e5c082f88 100644
--- a/src/heap/spaces.cc
+++ b/src/heap/spaces.cc
@@ -62,8 +62,10 @@ bool HeapObjectIterator::AdvanceToNextPage() {
}
cur_page = cur_page->next_page();
if (cur_page == space_->anchor()) return false;
- cur_page->heap()->mark_compact_collector()->SweepOrWaitUntilSweepingCompleted(
- cur_page);
+ cur_page->heap()
+ ->mark_compact_collector()
+ ->sweeper()
+ .SweepOrWaitUntilSweepingCompleted(cur_page);
cur_addr_ = cur_page->area_start();
cur_end_ = cur_page->area_end();
DCHECK(cur_page->SweepingDone());
@@ -1055,17 +1057,14 @@ void PagedSpace::RefillFreeList() {
return;
}
MarkCompactCollector* collector = heap()->mark_compact_collector();
- List<Page*>* swept_pages = collector->swept_pages(identity());
intptr_t added = 0;
{
- base::LockGuard<base::Mutex> guard(collector->swept_pages_mutex());
- for (int i = swept_pages->length() - 1; i >= 0; --i) {
- Page* p = (*swept_pages)[i];
+ Page* p = nullptr;
+ while ((p = collector->sweeper().GetSweptPageSafe(this)) != nullptr) {
// Only during compaction pages can actually change ownership. This is
// safe because there exists no other competing action on the page links
// during compaction.
if (is_local() && (p->owner() != this)) {
- if (added > kCompactionMemoryWanted) break;
base::LockGuard<base::Mutex> guard(
reinterpret_cast<PagedSpace*>(p->owner())->mutex());
p->Unlink();
@@ -1074,7 +1073,7 @@ void PagedSpace::RefillFreeList() {
}
added += RelinkFreeListCategories(p);
added += p->wasted_memory();
- swept_pages->Remove(i);
+ if (is_local() && (added > kCompactionMemoryWanted)) break;
}
}
accounting_stats_.IncreaseCapacity(added);
@@ -2623,8 +2622,8 @@ HeapObject* PagedSpace::SlowAllocateRaw(int size_in_bytes) {
if (object != NULL) return object;
// If sweeping is still in progress try to sweep pages on the main thread.
- int max_freed = collector->SweepInParallel(heap()->paged_space(identity()),
- size_in_bytes, kMaxPagesToSweep);
+ int max_freed = collector->sweeper().ParallelSweepSpace(
+ identity(), size_in_bytes, kMaxPagesToSweep);
RefillFreeList();
if (max_freed >= size_in_bytes) {
object = free_list_.Allocate(size_in_bytes);
« no previous file with comments | « src/heap/mark-compact-inl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698