| OLD | NEW |
| 1 // Copyright 2006-2010 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2010 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 1576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1587 int Free(Address start, int size_in_bytes); | 1587 int Free(Address start, int size_in_bytes); |
| 1588 | 1588 |
| 1589 // Allocate a block of size 'size_in_bytes' from the free list. The block | 1589 // Allocate a block of size 'size_in_bytes' from the free list. The block |
| 1590 // is unitialized. A failure is returned if no block is available. The | 1590 // is unitialized. A failure is returned if no block is available. The |
| 1591 // number of bytes lost to fragmentation is returned in the output parameter | 1591 // number of bytes lost to fragmentation is returned in the output parameter |
| 1592 // 'wasted_bytes'. The size should be a non-zero multiple of the word size. | 1592 // 'wasted_bytes'. The size should be a non-zero multiple of the word size. |
| 1593 MUST_USE_RESULT MaybeObject* Allocate(int size_in_bytes, int* wasted_bytes); | 1593 MUST_USE_RESULT MaybeObject* Allocate(int size_in_bytes, int* wasted_bytes); |
| 1594 | 1594 |
| 1595 void MarkNodes(); | 1595 void MarkNodes(); |
| 1596 | 1596 |
| 1597 #ifdef DEBUG |
| 1598 void Zap(); |
| 1599 #endif |
| 1600 |
| 1597 private: | 1601 private: |
| 1598 // The size range of blocks, in bytes. (Smaller allocations are allowed, but | 1602 // The size range of blocks, in bytes. (Smaller allocations are allowed, but |
| 1599 // will always result in waste.) | 1603 // will always result in waste.) |
| 1600 static const int kMinBlockSize = 2 * kPointerSize; | 1604 static const int kMinBlockSize = 2 * kPointerSize; |
| 1601 static const int kMaxBlockSize = Page::kMaxHeapObjectSize; | 1605 static const int kMaxBlockSize = Page::kMaxHeapObjectSize; |
| 1602 | 1606 |
| 1603 // The identity of the owning space, for building allocation Failure | 1607 // The identity of the owning space, for building allocation Failure |
| 1604 // objects. | 1608 // objects. |
| 1605 AllocationSpace owner_; | 1609 AllocationSpace owner_; |
| 1606 | 1610 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1687 // information will be written to the block, ie, its contents will be | 1691 // information will be written to the block, ie, its contents will be |
| 1688 // destroyed. The start address should be word aligned. | 1692 // destroyed. The start address should be word aligned. |
| 1689 void Free(Address start); | 1693 void Free(Address start); |
| 1690 | 1694 |
| 1691 // Allocate a fixed sized block from the free list. The block is unitialized. | 1695 // Allocate a fixed sized block from the free list. The block is unitialized. |
| 1692 // A failure is returned if no block is available. | 1696 // A failure is returned if no block is available. |
| 1693 MUST_USE_RESULT MaybeObject* Allocate(); | 1697 MUST_USE_RESULT MaybeObject* Allocate(); |
| 1694 | 1698 |
| 1695 void MarkNodes(); | 1699 void MarkNodes(); |
| 1696 | 1700 |
| 1701 #ifdef DEBUG |
| 1702 void Zap(); |
| 1703 #endif |
| 1704 |
| 1697 private: | 1705 private: |
| 1698 // Available bytes on the free list. | 1706 // Available bytes on the free list. |
| 1699 intptr_t available_; | 1707 intptr_t available_; |
| 1700 | 1708 |
| 1701 // The head of the free list. | 1709 // The head of the free list. |
| 1702 Address head_; | 1710 Address head_; |
| 1703 | 1711 |
| 1704 // The tail of the free list. | 1712 // The tail of the free list. |
| 1705 Address tail_; | 1713 Address tail_; |
| 1706 | 1714 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1759 // clears the free list. | 1767 // clears the free list. |
| 1760 virtual void PrepareForMarkCompact(bool will_compact); | 1768 virtual void PrepareForMarkCompact(bool will_compact); |
| 1761 | 1769 |
| 1762 virtual void PutRestOfCurrentPageOnFreeList(Page* current_page); | 1770 virtual void PutRestOfCurrentPageOnFreeList(Page* current_page); |
| 1763 | 1771 |
| 1764 void MarkFreeListNodes() { free_list_.MarkNodes(); } | 1772 void MarkFreeListNodes() { free_list_.MarkNodes(); } |
| 1765 | 1773 |
| 1766 #ifdef DEBUG | 1774 #ifdef DEBUG |
| 1767 // Reports statistics for the space | 1775 // Reports statistics for the space |
| 1768 void ReportStatistics(); | 1776 void ReportStatistics(); |
| 1777 |
| 1778 OldSpaceFreeList* free_list() { return &free_list_; } |
| 1769 #endif | 1779 #endif |
| 1770 | 1780 |
| 1771 protected: | 1781 protected: |
| 1772 // Virtual function in the superclass. Slow path of AllocateRaw. | 1782 // Virtual function in the superclass. Slow path of AllocateRaw. |
| 1773 MUST_USE_RESULT HeapObject* SlowAllocateRaw(int size_in_bytes); | 1783 MUST_USE_RESULT HeapObject* SlowAllocateRaw(int size_in_bytes); |
| 1774 | 1784 |
| 1775 // Virtual function in the superclass. Allocate linearly at the start of | 1785 // Virtual function in the superclass. Allocate linearly at the start of |
| 1776 // the page after current_page (there is assumed to be one). | 1786 // the page after current_page (there is assumed to be one). |
| 1777 HeapObject* AllocateInNextPage(Page* current_page, int size_in_bytes); | 1787 HeapObject* AllocateInNextPage(Page* current_page, int size_in_bytes); |
| 1778 | 1788 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1825 | 1835 |
| 1826 virtual void DeallocateBlock(Address start, | 1836 virtual void DeallocateBlock(Address start, |
| 1827 int size_in_bytes, | 1837 int size_in_bytes, |
| 1828 bool add_to_freelist); | 1838 bool add_to_freelist); |
| 1829 | 1839 |
| 1830 void MarkFreeListNodes() { free_list_.MarkNodes(); } | 1840 void MarkFreeListNodes() { free_list_.MarkNodes(); } |
| 1831 | 1841 |
| 1832 #ifdef DEBUG | 1842 #ifdef DEBUG |
| 1833 // Reports statistic info of the space | 1843 // Reports statistic info of the space |
| 1834 void ReportStatistics(); | 1844 void ReportStatistics(); |
| 1845 |
| 1846 FixedSizeFreeList* free_list() { return &free_list_; } |
| 1835 #endif | 1847 #endif |
| 1836 | 1848 |
| 1837 protected: | 1849 protected: |
| 1838 // Virtual function in the superclass. Slow path of AllocateRaw. | 1850 // Virtual function in the superclass. Slow path of AllocateRaw. |
| 1839 MUST_USE_RESULT HeapObject* SlowAllocateRaw(int size_in_bytes); | 1851 MUST_USE_RESULT HeapObject* SlowAllocateRaw(int size_in_bytes); |
| 1840 | 1852 |
| 1841 // Virtual function in the superclass. Allocate linearly at the start of | 1853 // Virtual function in the superclass. Allocate linearly at the start of |
| 1842 // the page after current_page (there is assumed to be one). | 1854 // the page after current_page (there is assumed to be one). |
| 1843 HeapObject* AllocateInNextPage(Page* current_page, int size_in_bytes); | 1855 HeapObject* AllocateInNextPage(Page* current_page, int size_in_bytes); |
| 1844 | 1856 |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2093 | 2105 |
| 2094 private: | 2106 private: |
| 2095 LargePage* current_; | 2107 LargePage* current_; |
| 2096 HeapObjectCallback size_func_; | 2108 HeapObjectCallback size_func_; |
| 2097 }; | 2109 }; |
| 2098 | 2110 |
| 2099 | 2111 |
| 2100 } } // namespace v8::internal | 2112 } } // namespace v8::internal |
| 2101 | 2113 |
| 2102 #endif // V8_SPACES_H_ | 2114 #endif // V8_SPACES_H_ |
| OLD | NEW |