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 909 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
920 | 920 |
921 // Checks whether page is currently in use by this space. | 921 // Checks whether page is currently in use by this space. |
922 bool IsUsed(Page* page); | 922 bool IsUsed(Page* page); |
923 | 923 |
924 // Clears remembered sets of pages in this space. | 924 // Clears remembered sets of pages in this space. |
925 void ClearRSet(); | 925 void ClearRSet(); |
926 | 926 |
927 // Prepares for a mark-compact GC. | 927 // Prepares for a mark-compact GC. |
928 virtual void PrepareForMarkCompact(bool will_compact); | 928 virtual void PrepareForMarkCompact(bool will_compact); |
929 | 929 |
930 virtual Address PageAllocationTop(Page* page) = 0; | 930 // The top of allocation in a page in this space. Undefined if page is unused. |
| 931 Address PageAllocationTop(Page* page) { |
| 932 return page == TopPageOf(allocation_info_) ? top() |
| 933 : PageAllocationLimit(page); |
| 934 } |
| 935 |
| 936 // The limit of allocation for a page in this space. |
| 937 virtual Address PageAllocationLimit(Page* page) = 0; |
931 | 938 |
932 // Current capacity without growing (Size() + Available() + Waste()). | 939 // Current capacity without growing (Size() + Available() + Waste()). |
933 int Capacity() { return accounting_stats_.Capacity(); } | 940 int Capacity() { return accounting_stats_.Capacity(); } |
934 | 941 |
935 // Total amount of memory committed for this space. For paged | 942 // Total amount of memory committed for this space. For paged |
936 // spaces this equals the capacity. | 943 // spaces this equals the capacity. |
937 int CommittedMemory() { return Capacity(); } | 944 int CommittedMemory() { return Capacity(); } |
938 | 945 |
939 // Available bytes without growing. | 946 // Available bytes without growing. |
940 int Available() { return accounting_stats_.Available(); } | 947 int Available() { return accounting_stats_.Available(); } |
(...skipping 22 matching lines...) Expand all Loading... |
963 virtual bool ReserveSpace(int bytes); | 970 virtual bool ReserveSpace(int bytes); |
964 | 971 |
965 // Used by ReserveSpace. | 972 // Used by ReserveSpace. |
966 virtual void PutRestOfCurrentPageOnFreeList(Page* current_page) = 0; | 973 virtual void PutRestOfCurrentPageOnFreeList(Page* current_page) = 0; |
967 | 974 |
968 // Free all pages in range from prev (exclusive) to last (inclusive). | 975 // Free all pages in range from prev (exclusive) to last (inclusive). |
969 // Freed pages are moved to the end of page list. | 976 // Freed pages are moved to the end of page list. |
970 void FreePages(Page* prev, Page* last); | 977 void FreePages(Page* prev, Page* last); |
971 | 978 |
972 // Set space allocation info. | 979 // Set space allocation info. |
973 void SetTop(Address top, Address limit) { | 980 void SetTop(Address top) { |
974 allocation_info_.top = top; | 981 allocation_info_.top = top; |
975 allocation_info_.limit = limit; | 982 allocation_info_.limit = PageAllocationLimit(Page::FromAllocationTop(top)); |
976 } | 983 } |
977 | 984 |
978 // --------------------------------------------------------------------------- | 985 // --------------------------------------------------------------------------- |
979 // Mark-compact collection support functions | 986 // Mark-compact collection support functions |
980 | 987 |
981 // Set the relocation point to the beginning of the space. | 988 // Set the relocation point to the beginning of the space. |
982 void MCResetRelocationInfo(); | 989 void MCResetRelocationInfo(); |
983 | 990 |
984 // Writes relocation info to the top page. | 991 // Writes relocation info to the top page. |
985 void MCWriteRelocationInfoToPage() { | 992 void MCWriteRelocationInfoToPage() { |
(...skipping 731 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1717 AllocationSpace id, | 1724 AllocationSpace id, |
1718 Executability executable) | 1725 Executability executable) |
1719 : PagedSpace(max_capacity, id, executable), free_list_(id) { | 1726 : PagedSpace(max_capacity, id, executable), free_list_(id) { |
1720 page_extra_ = 0; | 1727 page_extra_ = 0; |
1721 } | 1728 } |
1722 | 1729 |
1723 // The bytes available on the free list (ie, not above the linear allocation | 1730 // The bytes available on the free list (ie, not above the linear allocation |
1724 // pointer). | 1731 // pointer). |
1725 int AvailableFree() { return free_list_.available(); } | 1732 int AvailableFree() { return free_list_.available(); } |
1726 | 1733 |
1727 // The top of allocation in a page in this space. Undefined if page is unused. | 1734 // The limit of allocation for a page in this space. |
1728 virtual Address PageAllocationTop(Page* page) { | 1735 virtual Address PageAllocationLimit(Page* page) { |
1729 return page == TopPageOf(allocation_info_) ? top() : page->ObjectAreaEnd(); | 1736 return page->ObjectAreaEnd(); |
1730 } | 1737 } |
1731 | 1738 |
1732 // Give a block of memory to the space's free list. It might be added to | 1739 // Give a block of memory to the space's free list. It might be added to |
1733 // the free list or accounted as waste. | 1740 // the free list or accounted as waste. |
1734 // If add_to_freelist is false then just accounting stats are updated and | 1741 // If add_to_freelist is false then just accounting stats are updated and |
1735 // no attempt to add area to free list is made. | 1742 // no attempt to add area to free list is made. |
1736 void Free(Address start, int size_in_bytes, bool add_to_freelist) { | 1743 void Free(Address start, int size_in_bytes, bool add_to_freelist) { |
1737 accounting_stats_.DeallocateBytes(size_in_bytes); | 1744 accounting_stats_.DeallocateBytes(size_in_bytes); |
1738 | 1745 |
1739 if (add_to_freelist) { | 1746 if (add_to_freelist) { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1785 AllocationSpace id, | 1792 AllocationSpace id, |
1786 int object_size_in_bytes, | 1793 int object_size_in_bytes, |
1787 const char* name) | 1794 const char* name) |
1788 : PagedSpace(max_capacity, id, NOT_EXECUTABLE), | 1795 : PagedSpace(max_capacity, id, NOT_EXECUTABLE), |
1789 object_size_in_bytes_(object_size_in_bytes), | 1796 object_size_in_bytes_(object_size_in_bytes), |
1790 name_(name), | 1797 name_(name), |
1791 free_list_(id, object_size_in_bytes) { | 1798 free_list_(id, object_size_in_bytes) { |
1792 page_extra_ = Page::kObjectAreaSize % object_size_in_bytes; | 1799 page_extra_ = Page::kObjectAreaSize % object_size_in_bytes; |
1793 } | 1800 } |
1794 | 1801 |
1795 // The top of allocation in a page in this space. Undefined if page is unused. | 1802 // The limit of allocation for a page in this space. |
1796 virtual Address PageAllocationTop(Page* page) { | 1803 virtual Address PageAllocationLimit(Page* page) { |
1797 return page == TopPageOf(allocation_info_) ? top() | 1804 return page->ObjectAreaEnd() - page_extra_; |
1798 : page->ObjectAreaEnd() - page_extra_; | |
1799 } | 1805 } |
1800 | 1806 |
1801 int object_size_in_bytes() { return object_size_in_bytes_; } | 1807 int object_size_in_bytes() { return object_size_in_bytes_; } |
1802 | 1808 |
1803 // Give a fixed sized block of memory to the space's free list. | 1809 // Give a fixed sized block of memory to the space's free list. |
1804 // If add_to_freelist is false then just accounting stats are updated and | 1810 // If add_to_freelist is false then just accounting stats are updated and |
1805 // no attempt to add area to free list is made. | 1811 // no attempt to add area to free list is made. |
1806 void Free(Address start, bool add_to_freelist) { | 1812 void Free(Address start, bool add_to_freelist) { |
1807 if (add_to_freelist) { | 1813 if (add_to_freelist) { |
1808 free_list_.Free(start); | 1814 free_list_.Free(start); |
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2151 | 2157 |
2152 private: | 2158 private: |
2153 LargeObjectChunk* current_; | 2159 LargeObjectChunk* current_; |
2154 HeapObjectCallback size_func_; | 2160 HeapObjectCallback size_func_; |
2155 }; | 2161 }; |
2156 | 2162 |
2157 | 2163 |
2158 } } // namespace v8::internal | 2164 } } // namespace v8::internal |
2159 | 2165 |
2160 #endif // V8_SPACES_H_ | 2166 #endif // V8_SPACES_H_ |
OLD | NEW |