Commit a9374e2f authored by hpayer@chromium.org's avatar hpayer@chromium.org

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
parent 8924d03e
......@@ -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<intptr_t>(p));
}
p->set_parallel_sweeping(1);
space->IncreaseUnsweptFreeBytes(p);
break;
}
case PRECISE: {
......
......@@ -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.
......
......@@ -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<AtomicWord>(true));
start_sweeping_semaphore_->Signal();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment