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

Unified Diff: src/spaces.cc

Issue 11280120: Sweep pages with lowest live memory first. Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 9 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 701d46f38bc63473e56cc367caddabfc210f8657..b0c7241cc39e771fefd826dd53f88767cdd9dfb8 100644
--- a/src/spaces.cc
+++ b/src/spaces.cc
@@ -2503,14 +2503,39 @@ bool LargeObjectSpace::ReserveSpace(int bytes) {
}
+intptr_t PagedSpace::SweepPageWithLowestLiveMemory() {
+ Page* p = first_unswept_page_;
+ Page* sweep_canditate = NULL;
+
+ while (p != anchor()) {
+ if (ShouldBeSweptLazily(p) && !p->WasSweptConservatively()) {
+ if (sweep_canditate == NULL ||
+ p->LiveBytes() < sweep_canditate->LiveBytes()) {
+ sweep_canditate = p;
+ }
+ }
+ p = p->next_page();
+ }
+
+ if (sweep_canditate != NULL) {
+ DecreaseUnsweptFreeBytes(sweep_canditate);
+ return MarkCompactCollector::
+ SweepConservatively<MarkCompactCollector::SWEEP_SEQUENTIALLY>(
+ this, NULL, sweep_canditate);
+ }
+ return 0;
+}
+
+
bool PagedSpace::AdvanceSweeper(intptr_t bytes_to_sweep) {
if (IsLazySweepingComplete()) return true;
- intptr_t freed_bytes = 0;
+ intptr_t freed_bytes = SweepPageWithLowestLiveMemory();
+
Page* p = first_unswept_page_;
- do {
+ while (freed_bytes < bytes_to_sweep && p != anchor()) {
Page* next_page = p->next_page();
- if (ShouldBeSweptLazily(p)) {
+ if (ShouldBeSweptLazily(p) && !p->WasSweptConservatively()) {
if (FLAG_gc_verbose) {
PrintF("Sweeping 0x%" V8PRIxPTR " lazily advanced.\n",
reinterpret_cast<intptr_t>(p));
@@ -2522,7 +2547,7 @@ bool PagedSpace::AdvanceSweeper(intptr_t bytes_to_sweep) {
this, NULL, p);
}
p = next_page;
- } while (p != anchor() && freed_bytes < bytes_to_sweep);
+ }
if (p == anchor()) {
first_unswept_page_ = Page::FromAddress(NULL);
« 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