From: hpayer@chromium.org Date: Thu, 28 Feb 2013 15:07:28 +0000 (+0000) Subject: Set unswept free bytes for concurent sweeper. X-Git-Tag: upstream/4.7.83~14993 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a9374e2fea0b0e0b186a9cc48e34b500c45630b4;p=platform%2Fupstream%2Fv8.git Set unswept free bytes for concurent sweeper. BUG= Review URL: https://codereview.chromium.org/12184016 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@13776 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- diff --git a/src/mark-compact.cc b/src/mark-compact.cc index 6acf5f2..47a66a8 100644 --- a/src/mark-compact.cc +++ b/src/mark-compact.cc @@ -557,6 +557,8 @@ void MarkCompactCollector::WaitUntilSweepingCompleted() { sweeping_pending_ = false; StealMemoryFromSweeperThreads(heap()->paged_space(OLD_DATA_SPACE)); StealMemoryFromSweeperThreads(heap()->paged_space(OLD_POINTER_SPACE)); + heap()->paged_space(OLD_DATA_SPACE)->ResetUnsweptFreeBytes(); + heap()->paged_space(OLD_POINTER_SPACE)->ResetUnsweptFreeBytes(); } } @@ -567,6 +569,8 @@ intptr_t MarkCompactCollector:: for (int i = 0; i < FLAG_sweeper_threads; i++) { freed_bytes += heap()->isolate()->sweeper_threads()[i]->StealMemory(space); } + space->AddToAccountingStats(freed_bytes); + space->DecrementUnsweptFreeBytes(freed_bytes); return freed_bytes; } @@ -3843,6 +3847,7 @@ void MarkCompactCollector::SweepSpace(PagedSpace* space, SweeperType sweeper) { reinterpret_cast(p)); } p->set_parallel_sweeping(1); + space->IncreaseUnsweptFreeBytes(p); break; } case PRECISE: { diff --git a/src/spaces.h b/src/spaces.h index 3f8e395..02982cf 100644 --- a/src/spaces.h +++ b/src/spaces.h @@ -1630,6 +1630,11 @@ class PagedSpace : public Space { accounting_stats_.ClearSizeWaste(); } + // Increases the number of available bytes of that space. + void AddToAccountingStats(intptr_t bytes) { + accounting_stats_.DeallocateBytes(bytes); + } + // Available bytes without growing. These are the bytes on the free list. // The bytes in the linear allocation area are not included in this total // because updating the stats would slow down allocation. New pages are @@ -1749,11 +1754,19 @@ class PagedSpace : public Space { unswept_free_bytes_ += (p->area_size() - p->LiveBytes()); } + void DecrementUnsweptFreeBytes(int by) { + unswept_free_bytes_ -= by; + } + void DecreaseUnsweptFreeBytes(Page* p) { ASSERT(ShouldBeSweptLazily(p)); unswept_free_bytes_ -= (p->area_size() - p->LiveBytes()); } + void ResetUnsweptFreeBytes() { + unswept_free_bytes_ = 0; + } + bool AdvanceSweeper(intptr_t bytes_to_sweep); // When parallel sweeper threads are active this function waits @@ -1787,10 +1800,6 @@ class PagedSpace : public Space { protected: FreeList* free_list() { return &free_list_; } - void AddToAccountingStats(intptr_t bytes) { - accounting_stats_.DeallocateBytes(bytes); - } - int area_size_; // Maximum capacity of this space. diff --git a/src/sweeper-thread.cc b/src/sweeper-thread.cc index df5fcc6..f08fcfb 100644 --- a/src/sweeper-thread.cc +++ b/src/sweeper-thread.cc @@ -76,17 +76,15 @@ void SweeperThread::Run() { intptr_t SweeperThread::StealMemory(PagedSpace* space) { - intptr_t free_bytes = 0; if (space->identity() == OLD_POINTER_SPACE) { - free_bytes = space->free_list()->Concatenate(&free_list_old_pointer_space_); - space->AddToAccountingStats(free_bytes); + return space->free_list()->Concatenate(&free_list_old_pointer_space_); } else if (space->identity() == OLD_DATA_SPACE) { - free_bytes = space->free_list()->Concatenate(&free_list_old_data_space_); - space->AddToAccountingStats(free_bytes); + return space->free_list()->Concatenate(&free_list_old_data_space_); } - return free_bytes; + return 0; } + void SweeperThread::Stop() { Release_Store(&stop_thread_, static_cast(true)); start_sweeping_semaphore_->Signal();