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();
}
}
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;
}
reinterpret_cast<intptr_t>(p));
}
p->set_parallel_sweeping(1);
+ space->IncreaseUnsweptFreeBytes(p);
break;
}
case PRECISE: {
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
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
protected:
FreeList* free_list() { return &free_list_; }
- void AddToAccountingStats(intptr_t bytes) {
- accounting_stats_.DeallocateBytes(bytes);
- }
-
int area_size_;
// Maximum capacity of this space.
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();