| Index: src/spaces.h
|
| diff --git a/src/spaces.h b/src/spaces.h
|
| index 4d4ef4be7ee4c656e5d915cd25db2bd7e5806456..ec64e6e98d13797d0c8274e9df1e4bba5a5db651 100644
|
| --- a/src/spaces.h
|
| +++ b/src/spaces.h
|
| @@ -314,7 +314,10 @@ class Page : public MemoryChunk {
|
| static const int kObjectAreaSize = kPageSize - kObjectStartOffset;
|
|
|
| // Maximum object size that fits in a page.
|
| - static const int kMaxHeapObjectSize = kObjectAreaSize >> 4;
|
| + static const int kMaxHeapObjectSize =
|
| + OBJECT_POINTER_ALIGN(kObjectAreaSize >> 4);
|
| +
|
| + STATIC_ASSERT((kMaxHeapObjectSize & kObjectAlignmentMask) == 0);
|
|
|
| #ifdef ENABLE_CARDMARKING_WRITE_BARRIER
|
| static const int kDirtyFlagOffset = 2 * kPointerSize;
|
| @@ -1738,6 +1741,24 @@ class OldSpace : public PagedSpace {
|
| return page->ObjectAreaEnd();
|
| }
|
|
|
| + void AddToFreeList(Address start, int size_in_bytes) {
|
| + // TODO(gc) instead of putting large chunks into free list try to
|
| + // reuse them for linear allocation.
|
| + int wasted_bytes = 0;
|
| +
|
| + while (size_in_bytes >= Page::kMaxHeapObjectSize) {
|
| + wasted_bytes += free_list_.Free(start, Page::kMaxHeapObjectSize);
|
| + start += Page::kMaxHeapObjectSize;
|
| + size_in_bytes -= Page::kMaxHeapObjectSize;
|
| + }
|
| +
|
| + if (size_in_bytes > 0) {
|
| + wasted_bytes += free_list_.Free(start, size_in_bytes);
|
| + }
|
| +
|
| + accounting_stats_.WasteBytes(wasted_bytes);
|
| + }
|
| +
|
| // Give a block of memory to the space's free list. It might be added to
|
| // the free list or accounted as waste.
|
| // If add_to_freelist is false then just accounting stats are updated and
|
| @@ -1745,10 +1766,7 @@ class OldSpace : public PagedSpace {
|
| void Free(Address start, int size_in_bytes, bool add_to_freelist) {
|
| accounting_stats_.DeallocateBytes(size_in_bytes);
|
|
|
| - if (add_to_freelist) {
|
| - int wasted_bytes = free_list_.Free(start, size_in_bytes);
|
| - accounting_stats_.WasteBytes(wasted_bytes);
|
| - }
|
| + if (add_to_freelist) AddToFreeList(start, size_in_bytes);
|
| }
|
|
|
| virtual void DeallocateBlock(Address start,
|
|
|