Chromium Code Reviews| Index: src/spaces.h |
| diff --git a/src/spaces.h b/src/spaces.h |
| index 41bfec90f142797bdc295d622505ee963c6b05c6..1f1e20355b16d1dd3e247041334e642bb337142f 100644 |
| --- a/src/spaces.h |
| +++ b/src/spaces.h |
| @@ -1469,9 +1469,12 @@ class PagedSpace : public Space { |
| // linear allocation area (between top and limit) are also counted here. |
| virtual intptr_t Size() { return accounting_stats_.Size(); } |
| - // As size, but the bytes in the current linear allocation area are not |
| - // included. |
| - virtual intptr_t SizeOfObjects() { return Size() - (limit() - top()); } |
| + // As size, but the bytes in lazily swept pages are estimated and the bytes |
| + // in the current linear allocation area are not included. |
| + virtual intptr_t SizeOfObjects() { |
| + ASSERT(!IsSweepingComplete() || (unswept_dead_bytes_ == 0)); |
| + return Size() - unswept_dead_bytes_ - (limit() - top()); |
| + } |
| // Wasted bytes in this space. These are just the bytes that were thrown away |
| // due to being too small to use for allocation. They do not include the |
| @@ -1479,9 +1482,7 @@ class PagedSpace : public Space { |
| virtual intptr_t Waste() { return accounting_stats_.Waste(); } |
| // Returns the allocation pointer in this space. |
| - Address top() { |
| - return allocation_info_.top; |
| - } |
| + Address top() { return allocation_info_.top; } |
| Address limit() { return allocation_info_.limit; } |
| // Allocate the requested number of bytes in the space if possible, return a |
| @@ -1557,10 +1558,15 @@ class PagedSpace : public Space { |
| } |
| void SetPagesToSweep(Page* first) { |
| + ASSERT(unswept_dead_bytes_ == 0); |
| if (first == &anchor_) first = NULL; |
| first_unswept_page_ = first; |
| } |
| + void MarkPageForLazySweep(Page* p) { |
| + unswept_dead_bytes_ += (Page::kObjectAreaSize - p->LiveBytes()); |
| + } |
| + |
| bool AdvanceSweeper(intptr_t bytes_to_sweep); |
| bool IsSweepingComplete() { |
| @@ -1647,8 +1653,15 @@ class PagedSpace : public Space { |
| bool was_swept_conservatively_; |
| + // The first page to be swept when the lazy sweeper advances. Is set |
| + // to NULL when all pages have been swept. |
| Page* first_unswept_page_; |
| + // The number of dead bytes which could be reclaimed by advancing the |
| + // lazy sweeper. This is only an estimation because lazy sweeping is |
| + // done conservatively. |
| + intptr_t unswept_dead_bytes_; |
|
Vyacheslav Egorov (Chromium)
2012/01/11 10:16:49
I would call them free not dead (I think object ca
Michael Starzinger
2012/01/11 10:34:00
Done.
|
| + |
| // Expands the space by allocating a fixed number of pages. Returns false if |
| // it cannot allocate requested number of pages from OS, or if the hard heap |
| // size limit has been hit. |