Chromium Code Reviews| 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 964 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 975 int page_extra_; | 975 int page_extra_; |
| 976 | 976 |
| 977 // Sets allocation pointer to a page bottom. | 977 // Sets allocation pointer to a page bottom. |
| 978 static void SetAllocationInfo(AllocationInfo* alloc_info, Page* p); | 978 static void SetAllocationInfo(AllocationInfo* alloc_info, Page* p); |
| 979 | 979 |
| 980 // Returns the top page specified by an allocation info structure. | 980 // Returns the top page specified by an allocation info structure. |
| 981 static Page* TopPageOf(AllocationInfo alloc_info) { | 981 static Page* TopPageOf(AllocationInfo alloc_info) { |
| 982 return Page::FromAllocationTop(alloc_info.limit); | 982 return Page::FromAllocationTop(alloc_info.limit); |
| 983 } | 983 } |
| 984 | 984 |
| 985 int CountPagesToTop() { | |
| 986 Page* p = Page::FromAllocationTop(allocation_info_.top); | |
| 987 PageIterator it(this, PageIterator::ALL_PAGES); | |
| 988 int counter = 1; | |
| 989 while (it.has_next()) { | |
| 990 if (it.next() == p) return counter; | |
| 991 counter++; | |
| 992 } | |
| 993 UNREACHABLE(); | |
| 994 return -1; | |
| 995 } | |
| 996 | |
| 985 // Expands the space by allocating a fixed number of pages. Returns false if | 997 // Expands the space by allocating a fixed number of pages. Returns false if |
| 986 // it cannot allocate requested number of pages from OS. Newly allocated | 998 // it cannot allocate requested number of pages from OS. Newly allocated |
| 987 // pages are append to the last_page; | 999 // pages are append to the last_page; |
| 988 bool Expand(Page* last_page); | 1000 bool Expand(Page* last_page); |
| 989 | 1001 |
| 990 // Generic fast case allocation function that tries linear allocation in | 1002 // Generic fast case allocation function that tries linear allocation in |
| 991 // the top page of 'alloc_info'. Returns NULL on failure. | 1003 // the top page of 'alloc_info'. Returns NULL on failure. |
| 992 inline HeapObject* AllocateLinearly(AllocationInfo* alloc_info, | 1004 inline HeapObject* AllocateLinearly(AllocationInfo* alloc_info, |
| 993 int size_in_bytes); | 1005 int size_in_bytes); |
| 994 | 1006 |
| (...skipping 768 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1763 virtual void PrepareForMarkCompact(bool will_compact); | 1775 virtual void PrepareForMarkCompact(bool will_compact); |
| 1764 | 1776 |
| 1765 // Given an index, returns the page address. | 1777 // Given an index, returns the page address. |
| 1766 Address PageAddress(int page_index) { return page_addresses_[page_index]; } | 1778 Address PageAddress(int page_index) { return page_addresses_[page_index]; } |
| 1767 | 1779 |
| 1768 static const int kMaxMapPageIndex = 1 << MapWord::kMapPageIndexBits; | 1780 static const int kMaxMapPageIndex = 1 << MapWord::kMapPageIndexBits; |
| 1769 | 1781 |
| 1770 // Are map pointers encodable into map word? | 1782 // Are map pointers encodable into map word? |
| 1771 bool MapPointersEncodable() { | 1783 bool MapPointersEncodable() { |
| 1772 if (!FLAG_use_big_map_space) { | 1784 if (!FLAG_use_big_map_space) { |
| 1773 ASSERT(CountTotalPages() <= kMaxMapPageIndex); | 1785 ASSERT(CountPagesToTop() <= kMaxMapPageIndex); |
| 1774 return true; | 1786 return true; |
| 1775 } | 1787 } |
| 1776 int n_of_pages = Capacity() / Page::kObjectAreaSize; | 1788 return CountPagesToTop() <= max_map_space_pages_; |
| 1777 ASSERT(n_of_pages == CountTotalPages()); | |
| 1778 return n_of_pages <= max_map_space_pages_; | |
| 1779 } | 1789 } |
| 1780 | 1790 |
| 1781 // Should be called after forced sweep to find out if map space needs | 1791 // Should be called after forced sweep to find out if map space needs |
| 1782 // compaction. | 1792 // compaction. |
| 1783 bool NeedsCompaction(int live_maps) { | 1793 bool NeedsCompaction(int live_maps) { |
| 1784 return !MapPointersEncodable() && live_maps <= CompactionThreshold(); | 1794 return !MapPointersEncodable() && live_maps <= CompactionThreshold(); |
| 1785 } | 1795 } |
| 1786 | 1796 |
| 1787 Address TopAfterCompaction(int live_maps) { | 1797 Address TopAfterCompaction(int live_maps) { |
| 1788 ASSERT(NeedsCompaction(live_maps)); | 1798 ASSERT(NeedsCompaction(live_maps)); |
| 1789 | 1799 |
| 1790 int pages_left = live_maps / kMapsPerPage; | 1800 int pages_left = live_maps / kMapsPerPage; |
| 1791 PageIterator it(this, PageIterator::ALL_PAGES); | 1801 PageIterator it(this, PageIterator::ALL_PAGES); |
| 1792 while (pages_left-- > 0) { | 1802 while (pages_left-- > 0) { |
| 1803 it.has_next(); | |
|
Søren Thygesen Gjesse
2010/01/21 07:57:41
Please add a comment here.
| |
| 1793 ASSERT(it.has_next()); | 1804 ASSERT(it.has_next()); |
| 1794 it.next()->ClearRSet(); | 1805 it.next()->ClearRSet(); |
| 1795 } | 1806 } |
| 1807 it.has_next(); | |
|
Søren Thygesen Gjesse
2010/01/21 07:57:41
And here.
| |
| 1796 ASSERT(it.has_next()); | 1808 ASSERT(it.has_next()); |
| 1797 Page* top_page = it.next(); | 1809 Page* top_page = it.next(); |
| 1798 top_page->ClearRSet(); | 1810 top_page->ClearRSet(); |
| 1799 ASSERT(top_page->is_valid()); | 1811 ASSERT(top_page->is_valid()); |
| 1800 | 1812 |
| 1801 int offset = live_maps % kMapsPerPage * Map::kSize; | 1813 int offset = live_maps % kMapsPerPage * Map::kSize; |
| 1802 Address top = top_page->ObjectAreaStart() + offset; | 1814 Address top = top_page->ObjectAreaStart() + offset; |
| 1803 ASSERT(top < top_page->ObjectAreaEnd()); | 1815 ASSERT(top < top_page->ObjectAreaEnd()); |
| 1804 ASSERT(Contains(top)); | 1816 ASSERT(Contains(top)); |
| 1805 | 1817 |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2051 | 2063 |
| 2052 private: | 2064 private: |
| 2053 LargeObjectChunk* current_; | 2065 LargeObjectChunk* current_; |
| 2054 HeapObjectCallback size_func_; | 2066 HeapObjectCallback size_func_; |
| 2055 }; | 2067 }; |
| 2056 | 2068 |
| 2057 | 2069 |
| 2058 } } // namespace v8::internal | 2070 } } // namespace v8::internal |
| 2059 | 2071 |
| 2060 #endif // V8_SPACES_H_ | 2072 #endif // V8_SPACES_H_ |
| OLD | NEW |