| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_HEAP_SPACES_H_ | 5 #ifndef V8_HEAP_SPACES_H_ |
| 6 #define V8_HEAP_SPACES_H_ | 6 #define V8_HEAP_SPACES_H_ |
| 7 | 7 |
| 8 #include "src/allocation.h" | 8 #include "src/allocation.h" |
| 9 #include "src/base/atomicops.h" | 9 #include "src/base/atomicops.h" |
| 10 #include "src/base/bits.h" | 10 #include "src/base/bits.h" |
| (...skipping 1565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1576 | 1576 |
| 1577 private: | 1577 private: |
| 1578 // The size range of blocks, in bytes. | 1578 // The size range of blocks, in bytes. |
| 1579 static const int kMinBlockSize = 3 * kPointerSize; | 1579 static const int kMinBlockSize = 3 * kPointerSize; |
| 1580 static const int kMaxBlockSize = Page::kMaxRegularHeapObjectSize; | 1580 static const int kMaxBlockSize = Page::kMaxRegularHeapObjectSize; |
| 1581 | 1581 |
| 1582 FreeSpace* FindNodeFor(int size_in_bytes, int* node_size); | 1582 FreeSpace* FindNodeFor(int size_in_bytes, int* node_size); |
| 1583 | 1583 |
| 1584 PagedSpace* owner_; | 1584 PagedSpace* owner_; |
| 1585 Heap* heap_; | 1585 Heap* heap_; |
| 1586 int unreported_allocation_; | |
| 1587 | 1586 |
| 1588 static const int kSmallListMax = 0xff * kPointerSize; | 1587 static const int kSmallListMax = 0xff * kPointerSize; |
| 1589 static const int kMediumListMax = 0x7ff * kPointerSize; | 1588 static const int kMediumListMax = 0x7ff * kPointerSize; |
| 1590 static const int kLargeListMax = 0x3fff * kPointerSize; | 1589 static const int kLargeListMax = 0x3fff * kPointerSize; |
| 1591 static const int kSmallAllocationMax = kSmallListMin - kPointerSize; | 1590 static const int kSmallAllocationMax = kSmallListMin - kPointerSize; |
| 1592 static const int kMediumAllocationMax = kSmallListMax; | 1591 static const int kMediumAllocationMax = kSmallListMax; |
| 1593 static const int kLargeAllocationMax = kMediumListMax; | 1592 static const int kLargeAllocationMax = kMediumListMax; |
| 1594 FreeListCategory small_list_; | 1593 FreeListCategory small_list_; |
| 1595 FreeListCategory medium_list_; | 1594 FreeListCategory medium_list_; |
| 1596 FreeListCategory large_list_; | 1595 FreeListCategory large_list_; |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1774 int Free(Address start, int size_in_bytes) { | 1773 int Free(Address start, int size_in_bytes) { |
| 1775 int wasted = free_list_.Free(start, size_in_bytes); | 1774 int wasted = free_list_.Free(start, size_in_bytes); |
| 1776 accounting_stats_.DeallocateBytes(size_in_bytes); | 1775 accounting_stats_.DeallocateBytes(size_in_bytes); |
| 1777 accounting_stats_.WasteBytes(wasted); | 1776 accounting_stats_.WasteBytes(wasted); |
| 1778 return size_in_bytes - wasted; | 1777 return size_in_bytes - wasted; |
| 1779 } | 1778 } |
| 1780 | 1779 |
| 1781 void ResetFreeList() { free_list_.Reset(); } | 1780 void ResetFreeList() { free_list_.Reset(); } |
| 1782 | 1781 |
| 1783 // Set space allocation info. | 1782 // Set space allocation info. |
| 1784 void SetTopAndLimit(Address top, Address limit); | 1783 void SetTopAndLimit(Address top, Address limit) { |
| 1784 DCHECK(top == limit || |
| 1785 Page::FromAddress(top) == Page::FromAddress(limit - 1)); |
| 1786 MemoryChunk::UpdateHighWaterMark(allocation_info_.top()); |
| 1787 allocation_info_.set_top(top); |
| 1788 allocation_info_.set_limit(limit); |
| 1789 } |
| 1785 | 1790 |
| 1786 // Empty space allocation info, returning unused area to free list. | 1791 // Empty space allocation info, returning unused area to free list. |
| 1787 void EmptyAllocationInfo() { | 1792 void EmptyAllocationInfo() { |
| 1788 // Mark the old linear allocation area with a free space map so it can be | 1793 // Mark the old linear allocation area with a free space map so it can be |
| 1789 // skipped when scanning the heap. | 1794 // skipped when scanning the heap. |
| 1790 int old_linear_size = static_cast<int>(limit() - top()); | 1795 int old_linear_size = static_cast<int>(limit() - top()); |
| 1791 Free(top(), old_linear_size); | 1796 Free(top(), old_linear_size); |
| 1792 SetTopAndLimit(NULL, NULL); | 1797 SetTopAndLimit(NULL, NULL); |
| 1793 } | 1798 } |
| 1794 | 1799 |
| (...skipping 1060 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2855 count = 0; | 2860 count = 0; |
| 2856 } | 2861 } |
| 2857 // Must be small, since an iteration is used for lookup. | 2862 // Must be small, since an iteration is used for lookup. |
| 2858 static const int kMaxComments = 64; | 2863 static const int kMaxComments = 64; |
| 2859 }; | 2864 }; |
| 2860 #endif | 2865 #endif |
| 2861 } | 2866 } |
| 2862 } // namespace v8::internal | 2867 } // namespace v8::internal |
| 2863 | 2868 |
| 2864 #endif // V8_HEAP_SPACES_H_ | 2869 #endif // V8_HEAP_SPACES_H_ |
| OLD | NEW |