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

Unified Diff: src/spaces.h

Issue 8692002: Only sweep one page eagerly unless we are running out of space. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 9 years, 1 month 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/objects.cc ('k') | src/spaces.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/spaces.h
===================================================================
--- src/spaces.h (revision 10059)
+++ src/spaces.h (working copy)
@@ -1557,6 +1557,7 @@
}
void SetPagesToSweep(Page* first) {
+ if (first == &anchor_) first = NULL;
first_unswept_page_ = first;
}
@@ -1569,7 +1570,10 @@
Page* FirstPage() { return anchor_.next_page(); }
Page* LastPage() { return anchor_.prev_page(); }
- bool IsFragmented(Page* p) {
+ // Returns zero for pages that have so little fragmentation that it is not
+ // worth defragmenting them. Otherwise a positive integer that gives an
+ // estimate of fragmentation on an arbitrary scale.
+ int Fragmentation(Page* p) {
FreeList::SizeStats sizes;
free_list_.CountFreeListItems(p, &sizes);
@@ -1604,14 +1608,21 @@
(ratio > ratio_threshold) ? "[fragmented]" : "");
}
- return (ratio > ratio_threshold) ||
- (FLAG_always_compact && sizes.Total() != Page::kObjectAreaSize);
+ if (FLAG_always_compact && sizes.Total() != Page::kObjectAreaSize) {
+ return 1;
+ }
+ if (ratio <= ratio_threshold) return 0; // Not fragmented.
+
+ return static_cast<int>(ratio - ratio_threshold);
}
void EvictEvacuationCandidatesFromFreeLists();
bool CanExpand();
+ // Returns the number of total pages in this space.
+ int CountTotalPages();
+
protected:
// Maximum capacity of this space.
intptr_t max_capacity_;
@@ -1649,11 +1660,6 @@
// Slow path of AllocateRaw. This function is space-dependent.
MUST_USE_RESULT virtual HeapObject* SlowAllocateRaw(int size_in_bytes);
-#ifdef DEBUG
- // Returns the number of total pages in this space.
- int CountTotalPages();
-#endif
-
friend class PageIterator;
};
« no previous file with comments | « src/objects.cc ('k') | src/spaces.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698