OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 1612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1623 | 1623 |
1624 // Sets the capacity, the available space and the wasted space to zero. | 1624 // Sets the capacity, the available space and the wasted space to zero. |
1625 // The stats are rebuilt during sweeping by adding each page to the | 1625 // The stats are rebuilt during sweeping by adding each page to the |
1626 // capacity and the size when it is encountered. As free spaces are | 1626 // capacity and the size when it is encountered. As free spaces are |
1627 // discovered during the sweeping they are subtracted from the size and added | 1627 // discovered during the sweeping they are subtracted from the size and added |
1628 // to the available and wasted totals. | 1628 // to the available and wasted totals. |
1629 void ClearStats() { | 1629 void ClearStats() { |
1630 accounting_stats_.ClearSizeWaste(); | 1630 accounting_stats_.ClearSizeWaste(); |
1631 } | 1631 } |
1632 | 1632 |
| 1633 // Increases the number of available bytes of that space. |
| 1634 void AddToAccountingStats(intptr_t bytes) { |
| 1635 accounting_stats_.DeallocateBytes(bytes); |
| 1636 } |
| 1637 |
1633 // Available bytes without growing. These are the bytes on the free list. | 1638 // Available bytes without growing. These are the bytes on the free list. |
1634 // The bytes in the linear allocation area are not included in this total | 1639 // The bytes in the linear allocation area are not included in this total |
1635 // because updating the stats would slow down allocation. New pages are | 1640 // because updating the stats would slow down allocation. New pages are |
1636 // immediately added to the free list so they show up here. | 1641 // immediately added to the free list so they show up here. |
1637 intptr_t Available() { return free_list_.available(); } | 1642 intptr_t Available() { return free_list_.available(); } |
1638 | 1643 |
1639 // Allocated bytes in this space. Garbage bytes that were not found due to | 1644 // Allocated bytes in this space. Garbage bytes that were not found due to |
1640 // lazy sweeping are counted as being allocated! The bytes in the current | 1645 // lazy sweeping are counted as being allocated! The bytes in the current |
1641 // linear allocation area (between top and limit) are also counted here. | 1646 // linear allocation area (between top and limit) are also counted here. |
1642 virtual intptr_t Size() { return accounting_stats_.Size(); } | 1647 virtual intptr_t Size() { return accounting_stats_.Size(); } |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1742 | 1747 |
1743 void IncrementUnsweptFreeBytes(int by) { | 1748 void IncrementUnsweptFreeBytes(int by) { |
1744 unswept_free_bytes_ += by; | 1749 unswept_free_bytes_ += by; |
1745 } | 1750 } |
1746 | 1751 |
1747 void IncreaseUnsweptFreeBytes(Page* p) { | 1752 void IncreaseUnsweptFreeBytes(Page* p) { |
1748 ASSERT(ShouldBeSweptLazily(p)); | 1753 ASSERT(ShouldBeSweptLazily(p)); |
1749 unswept_free_bytes_ += (p->area_size() - p->LiveBytes()); | 1754 unswept_free_bytes_ += (p->area_size() - p->LiveBytes()); |
1750 } | 1755 } |
1751 | 1756 |
| 1757 void DecrementUnsweptFreeBytes(int by) { |
| 1758 unswept_free_bytes_ -= by; |
| 1759 } |
| 1760 |
1752 void DecreaseUnsweptFreeBytes(Page* p) { | 1761 void DecreaseUnsweptFreeBytes(Page* p) { |
1753 ASSERT(ShouldBeSweptLazily(p)); | 1762 ASSERT(ShouldBeSweptLazily(p)); |
1754 unswept_free_bytes_ -= (p->area_size() - p->LiveBytes()); | 1763 unswept_free_bytes_ -= (p->area_size() - p->LiveBytes()); |
1755 } | 1764 } |
1756 | 1765 |
| 1766 void ResetUnsweptFreeBytes() { |
| 1767 unswept_free_bytes_ = 0; |
| 1768 } |
| 1769 |
1757 bool AdvanceSweeper(intptr_t bytes_to_sweep); | 1770 bool AdvanceSweeper(intptr_t bytes_to_sweep); |
1758 | 1771 |
1759 // When parallel sweeper threads are active this function waits | 1772 // When parallel sweeper threads are active this function waits |
1760 // for them to complete, otherwise AdvanceSweeper with size_in_bytes | 1773 // for them to complete, otherwise AdvanceSweeper with size_in_bytes |
1761 // is called. | 1774 // is called. |
1762 bool EnsureSweeperProgress(intptr_t size_in_bytes); | 1775 bool EnsureSweeperProgress(intptr_t size_in_bytes); |
1763 | 1776 |
1764 bool IsLazySweepingComplete() { | 1777 bool IsLazySweepingComplete() { |
1765 return !first_unswept_page_->is_valid(); | 1778 return !first_unswept_page_->is_valid(); |
1766 } | 1779 } |
(...skipping 13 matching lines...) Expand all Loading... |
1780 int CountTotalPages(); | 1793 int CountTotalPages(); |
1781 | 1794 |
1782 // Return size of allocatable area on a page in this space. | 1795 // Return size of allocatable area on a page in this space. |
1783 inline int AreaSize() { | 1796 inline int AreaSize() { |
1784 return area_size_; | 1797 return area_size_; |
1785 } | 1798 } |
1786 | 1799 |
1787 protected: | 1800 protected: |
1788 FreeList* free_list() { return &free_list_; } | 1801 FreeList* free_list() { return &free_list_; } |
1789 | 1802 |
1790 void AddToAccountingStats(intptr_t bytes) { | |
1791 accounting_stats_.DeallocateBytes(bytes); | |
1792 } | |
1793 | |
1794 int area_size_; | 1803 int area_size_; |
1795 | 1804 |
1796 // Maximum capacity of this space. | 1805 // Maximum capacity of this space. |
1797 intptr_t max_capacity_; | 1806 intptr_t max_capacity_; |
1798 | 1807 |
1799 intptr_t SizeOfFirstPage(); | 1808 intptr_t SizeOfFirstPage(); |
1800 | 1809 |
1801 // Accounting information for this space. | 1810 // Accounting information for this space. |
1802 AllocationStats accounting_stats_; | 1811 AllocationStats accounting_stats_; |
1803 | 1812 |
(...skipping 1014 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2818 } | 2827 } |
2819 // Must be small, since an iteration is used for lookup. | 2828 // Must be small, since an iteration is used for lookup. |
2820 static const int kMaxComments = 64; | 2829 static const int kMaxComments = 64; |
2821 }; | 2830 }; |
2822 #endif | 2831 #endif |
2823 | 2832 |
2824 | 2833 |
2825 } } // namespace v8::internal | 2834 } } // namespace v8::internal |
2826 | 2835 |
2827 #endif // V8_SPACES_H_ | 2836 #endif // V8_SPACES_H_ |
OLD | NEW |