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

Unified Diff: src/spaces.cc

Issue 7891010: Implement shrinking of paged spaces during sweeping. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/gc
Patch Set: Added tracing output. Created 9 years, 3 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/spaces.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/spaces.cc
diff --git a/src/spaces.cc b/src/spaces.cc
index 9ae2e625d042076a279512f7b3223d2b884df1e3..027b165a472f8f9d16db79d38208fa8048df2565 100644
--- a/src/spaces.cc
+++ b/src/spaces.cc
@@ -761,8 +761,30 @@ int PagedSpace::CountTotalPages() {
#endif
-void PagedSpace::Shrink() {
- // TODO(1614) Not implemented.
+void PagedSpace::ReleasePage(Page* page) {
+ ASSERT(page->LiveBytes() == 0);
+ page->Unlink();
+ if (page->IsFlagSet(MemoryChunk::CONTAINS_ONLY_DATA)) {
+ heap()->isolate()->memory_allocator()->Free(page);
+ } else {
+ heap()->QueueMemoryChunkForFree(page);
+ }
+
+ ASSERT(Capacity() > 0);
+ ASSERT(Capacity() % Page::kObjectAreaSize == 0);
+ accounting_stats_.ShrinkSpace(Page::kObjectAreaSize);
+}
+
+
+void PagedSpace::ReleaseAllUnusedPages() {
+ PageIterator it(this);
+ while (it.has_next()) {
+ Page* page = it.next();
+ if (page->LiveBytes() == 0) {
+ ReleasePage(page);
+ }
+ }
+ heap()->FreeQueuedChunks();
}
@@ -1647,25 +1669,6 @@ void FreeList::Reset() {
}
-int PagedSpace::FreeOrUnmapPage(Page* page, Address start, int size_in_bytes) {
- Heap* heap = page->heap();
- // TODO(gc): When we count the live bytes per page we can free empty pages
- // instead of sweeping. At that point this if should be turned into an
- // ASSERT that the area to be freed cannot be the entire page.
- if (size_in_bytes == Page::kObjectAreaSize &&
- heap->ShouldWeGiveBackAPageToTheOS()) {
- page->Unlink();
- if (page->IsFlagSet(MemoryChunk::CONTAINS_ONLY_DATA)) {
- heap->isolate()->memory_allocator()->Free(page);
- } else {
- heap->QueueMemoryChunkForFree(page);
- }
- return 0;
- }
- return Free(start, size_in_bytes);
-}
-
-
int FreeList::Free(Address start, int size_in_bytes) {
if (size_in_bytes == 0) return 0;
FreeListNode* node = FreeListNode::FromAddress(start);
@@ -1918,7 +1921,7 @@ void PagedSpace::PrepareForMarkCompact() {
// Stop lazy sweeping and clear marking bits for unswept pages.
if (first_unswept_page_ != NULL) {
- Page* last = last_unswept_page_->next_page();
+ Page* last = last_unswept_page_;
Page* p = first_unswept_page_;
do {
// Do not use ShouldBeSweptLazily predicate here.
@@ -1975,7 +1978,7 @@ bool PagedSpace::AdvanceSweeper(intptr_t bytes_to_sweep) {
if (IsSweepingComplete()) return true;
intptr_t freed_bytes = 0;
- Page* last = last_unswept_page_->next_page();
+ Page* last = last_unswept_page_;
Page* p = first_unswept_page_;
do {
Page* next_page = p->next_page();
« no previous file with comments | « src/spaces.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698