OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 1735 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1746 FixedSizeFreeList free_list_; | 1746 FixedSizeFreeList free_list_; |
1747 }; | 1747 }; |
1748 | 1748 |
1749 | 1749 |
1750 // ----------------------------------------------------------------------------- | 1750 // ----------------------------------------------------------------------------- |
1751 // Old space for all map objects | 1751 // Old space for all map objects |
1752 | 1752 |
1753 class MapSpace : public FixedSpace { | 1753 class MapSpace : public FixedSpace { |
1754 public: | 1754 public: |
1755 // Creates a map space object with a maximum capacity. | 1755 // Creates a map space object with a maximum capacity. |
1756 MapSpace(int max_capacity, AllocationSpace id) | 1756 MapSpace(int max_capacity, int max_map_space_pages, AllocationSpace id) |
1757 : FixedSpace(max_capacity, id, Map::kSize, "map") {} | 1757 : FixedSpace(max_capacity, id, Map::kSize, "map"), |
| 1758 max_map_space_pages_(max_map_space_pages) { |
| 1759 ASSERT(max_map_space_pages < kMaxMapPageIndex); |
| 1760 } |
1758 | 1761 |
1759 // Prepares for a mark-compact GC. | 1762 // Prepares for a mark-compact GC. |
1760 virtual void PrepareForMarkCompact(bool will_compact); | 1763 virtual void PrepareForMarkCompact(bool will_compact); |
1761 | 1764 |
1762 // Given an index, returns the page address. | 1765 // Given an index, returns the page address. |
1763 Address PageAddress(int page_index) { return page_addresses_[page_index]; } | 1766 Address PageAddress(int page_index) { return page_addresses_[page_index]; } |
1764 | 1767 |
1765 // Constants. | 1768 static const int kMaxMapPageIndex = 1 << MapWord::kMapPageIndexBits; |
1766 static const int kMaxMapPageIndex = (1 << MapWord::kMapPageIndexBits) - 1; | |
1767 | 1769 |
1768 // Are map pointers encodable into map word? | 1770 // Are map pointers encodable into map word? |
1769 bool MapPointersEncodable() { | 1771 bool MapPointersEncodable() { |
1770 if (!FLAG_use_big_map_space) { | 1772 if (!FLAG_use_big_map_space) { |
1771 ASSERT(CountTotalPages() <= kMaxMapPageIndex); | 1773 ASSERT(CountTotalPages() <= kMaxMapPageIndex); |
1772 return true; | 1774 return true; |
1773 } | 1775 } |
1774 int n_of_pages = Capacity() / Page::kObjectAreaSize; | 1776 int n_of_pages = Capacity() / Page::kObjectAreaSize; |
1775 ASSERT(n_of_pages == CountTotalPages()); | 1777 ASSERT(n_of_pages == CountTotalPages()); |
1776 return n_of_pages <= kMaxMapPageIndex; | 1778 return n_of_pages <= max_map_space_pages_; |
1777 } | 1779 } |
1778 | 1780 |
1779 // Should be called after forced sweep to find out if map space needs | 1781 // Should be called after forced sweep to find out if map space needs |
1780 // compaction. | 1782 // compaction. |
1781 bool NeedsCompaction(int live_maps) { | 1783 bool NeedsCompaction(int live_maps) { |
1782 return !MapPointersEncodable() && live_maps <= kCompactionThreshold; | 1784 return !MapPointersEncodable() && live_maps <= CompactionThreshold(); |
1783 } | 1785 } |
1784 | 1786 |
1785 Address TopAfterCompaction(int live_maps) { | 1787 Address TopAfterCompaction(int live_maps) { |
1786 ASSERT(NeedsCompaction(live_maps)); | 1788 ASSERT(NeedsCompaction(live_maps)); |
1787 | 1789 |
1788 int pages_left = live_maps / kMapsPerPage; | 1790 int pages_left = live_maps / kMapsPerPage; |
1789 PageIterator it(this, PageIterator::ALL_PAGES); | 1791 PageIterator it(this, PageIterator::ALL_PAGES); |
1790 while (pages_left-- > 0) { | 1792 while (pages_left-- > 0) { |
1791 ASSERT(it.has_next()); | 1793 ASSERT(it.has_next()); |
1792 it.next()->ClearRSet(); | 1794 it.next()->ClearRSet(); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1831 | 1833 |
1832 protected: | 1834 protected: |
1833 #ifdef DEBUG | 1835 #ifdef DEBUG |
1834 virtual void VerifyObject(HeapObject* obj); | 1836 virtual void VerifyObject(HeapObject* obj); |
1835 #endif | 1837 #endif |
1836 | 1838 |
1837 private: | 1839 private: |
1838 static const int kMapsPerPage = Page::kObjectAreaSize / Map::kSize; | 1840 static const int kMapsPerPage = Page::kObjectAreaSize / Map::kSize; |
1839 | 1841 |
1840 // Do map space compaction if there is a page gap. | 1842 // Do map space compaction if there is a page gap. |
1841 static const int kCompactionThreshold = kMapsPerPage * (kMaxMapPageIndex - 1); | 1843 int CompactionThreshold() { |
| 1844 return kMapsPerPage * (max_map_space_pages_ - 1); |
| 1845 } |
| 1846 |
| 1847 const int max_map_space_pages_; |
1842 | 1848 |
1843 // An array of page start address in a map space. | 1849 // An array of page start address in a map space. |
1844 Address page_addresses_[kMaxMapPageIndex + 1]; | 1850 Address page_addresses_[kMaxMapPageIndex]; |
1845 | 1851 |
1846 public: | 1852 public: |
1847 TRACK_MEMORY("MapSpace") | 1853 TRACK_MEMORY("MapSpace") |
1848 }; | 1854 }; |
1849 | 1855 |
1850 | 1856 |
1851 // ----------------------------------------------------------------------------- | 1857 // ----------------------------------------------------------------------------- |
1852 // Old space for all global object property cell objects | 1858 // Old space for all global object property cell objects |
1853 | 1859 |
1854 class CellSpace : public FixedSpace { | 1860 class CellSpace : public FixedSpace { |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2045 | 2051 |
2046 private: | 2052 private: |
2047 LargeObjectChunk* current_; | 2053 LargeObjectChunk* current_; |
2048 HeapObjectCallback size_func_; | 2054 HeapObjectCallback size_func_; |
2049 }; | 2055 }; |
2050 | 2056 |
2051 | 2057 |
2052 } } // namespace v8::internal | 2058 } } // namespace v8::internal |
2053 | 2059 |
2054 #endif // V8_SPACES_H_ | 2060 #endif // V8_SPACES_H_ |
OLD | NEW |