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

Unified Diff: src/heap/spaces.cc

Issue 1596343004: [heap] Sort sweep pages list by free memory. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Adressed final comment Created 4 years, 11 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/spaces.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 90d252abb592a46a051864883c30c6bd44b436b3..cdf1a193b60295099d38b111f09ebba3f550a9f8 100644
--- a/src/heap/spaces.cc
+++ b/src/heap/spaces.cc
@@ -952,9 +952,7 @@ STATIC_ASSERT(static_cast<ObjectSpace>(1 << AllocationSpace::MAP_SPACE) ==
PagedSpace::PagedSpace(Heap* heap, AllocationSpace space,
Executability executable)
- : Space(heap, space, executable),
- free_list_(this),
- end_of_unswept_pages_(NULL) {
+ : Space(heap, space, executable), free_list_(this) {
area_size_ = MemoryAllocator::PageAreaSize(space);
accounting_stats_.Clear();
@@ -1109,8 +1107,6 @@ void PagedSpace::MergeCompactionSpace(CompactionSpace* other) {
DCHECK(other->top() == nullptr);
DCHECK(other->limit() == nullptr);
- DCHECK(other->end_of_unswept_pages_ == nullptr);
-
AccountCommitted(other->CommittedMemory());
// Move over pages.
@@ -2837,6 +2833,8 @@ HeapObject* CompactionSpace::SweepAndRetryAllocation(int size_in_bytes) {
HeapObject* PagedSpace::SlowAllocateRaw(int size_in_bytes) {
+ const int kMaxPagesToSweep = 1;
+
// Allocation in this space has failed.
MarkCompactCollector* collector = heap()->mark_compact_collector();
@@ -2851,10 +2849,13 @@ 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.
- collector->SweepInParallel(heap()->paged_space(identity()), size_in_bytes);
+ int max_freed = collector->SweepInParallel(heap()->paged_space(identity()),
+ size_in_bytes, kMaxPagesToSweep);
RefillFreeList();
- object = free_list_.Allocate(size_in_bytes);
- if (object != nullptr) return object;
+ if (max_freed >= size_in_bytes) {
+ object = free_list_.Allocate(size_in_bytes);
+ if (object != nullptr) return object;
+ }
}
// Free list allocation failed and there is no next page. Fail if we have
« no previous file with comments | « src/heap/spaces.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698