| 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);
|
|
|