| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_HEAP_SPACES_H_ | 5 #ifndef V8_HEAP_SPACES_H_ |
| 6 #define V8_HEAP_SPACES_H_ | 6 #define V8_HEAP_SPACES_H_ |
| 7 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <unordered_set> | 10 #include <unordered_set> |
| (...skipping 1625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1636 // 256-2047 words (medium): Used for allocating free space between 32-255 words | 1636 // 256-2047 words (medium): Used for allocating free space between 32-255 words |
| 1637 // in size. | 1637 // in size. |
| 1638 // 1048-16383 words (large): Used for allocating free space between 256-2047 | 1638 // 1048-16383 words (large): Used for allocating free space between 256-2047 |
| 1639 // words in size. | 1639 // words in size. |
| 1640 // At least 16384 words (huge): This list is for objects of 2048 words or | 1640 // At least 16384 words (huge): This list is for objects of 2048 words or |
| 1641 // larger. Empty pages are also added to this list. | 1641 // larger. Empty pages are also added to this list. |
| 1642 class FreeList { | 1642 class FreeList { |
| 1643 public: | 1643 public: |
| 1644 // This method returns how much memory can be allocated after freeing | 1644 // This method returns how much memory can be allocated after freeing |
| 1645 // maximum_freed memory. | 1645 // maximum_freed memory. |
| 1646 static inline int GuaranteedAllocatable(int maximum_freed) { | 1646 static inline size_t GuaranteedAllocatable(size_t maximum_freed) { |
| 1647 if (maximum_freed <= kTiniestListMax) { | 1647 if (maximum_freed <= kTiniestListMax) { |
| 1648 // Since we are not iterating over all list entries, we cannot guarantee | 1648 // Since we are not iterating over all list entries, we cannot guarantee |
| 1649 // that we can find the maximum freed block in that free list. | 1649 // that we can find the maximum freed block in that free list. |
| 1650 return 0; | 1650 return 0; |
| 1651 } else if (maximum_freed <= kTinyListMax) { | 1651 } else if (maximum_freed <= kTinyListMax) { |
| 1652 return kTinyAllocationMax; | 1652 return kTinyAllocationMax; |
| 1653 } else if (maximum_freed <= kSmallListMax) { | 1653 } else if (maximum_freed <= kSmallListMax) { |
| 1654 return kSmallAllocationMax; | 1654 return kSmallAllocationMax; |
| 1655 } else if (maximum_freed <= kMediumListMax) { | 1655 } else if (maximum_freed <= kMediumListMax) { |
| 1656 return kMediumAllocationMax; | 1656 return kMediumAllocationMax; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1678 // Clear the free list. | 1678 // Clear the free list. |
| 1679 void Reset(); | 1679 void Reset(); |
| 1680 | 1680 |
| 1681 void ResetStats() { | 1681 void ResetStats() { |
| 1682 wasted_bytes_.SetValue(0); | 1682 wasted_bytes_.SetValue(0); |
| 1683 ForAllFreeListCategories( | 1683 ForAllFreeListCategories( |
| 1684 [](FreeListCategory* category) { category->ResetStats(); }); | 1684 [](FreeListCategory* category) { category->ResetStats(); }); |
| 1685 } | 1685 } |
| 1686 | 1686 |
| 1687 // Return the number of bytes available on the free list. | 1687 // Return the number of bytes available on the free list. |
| 1688 intptr_t Available() { | 1688 size_t Available() { |
| 1689 intptr_t available = 0; | 1689 size_t available = 0; |
| 1690 ForAllFreeListCategories([&available](FreeListCategory* category) { | 1690 ForAllFreeListCategories([&available](FreeListCategory* category) { |
| 1691 available += category->available(); | 1691 available += category->available(); |
| 1692 }); | 1692 }); |
| 1693 return available; | 1693 return available; |
| 1694 } | 1694 } |
| 1695 | 1695 |
| 1696 bool IsEmpty() { | 1696 bool IsEmpty() { |
| 1697 bool empty = true; | 1697 bool empty = true; |
| 1698 ForAllFreeListCategories([&empty](FreeListCategory* category) { | 1698 ForAllFreeListCategories([&empty](FreeListCategory* category) { |
| 1699 if (!category->is_empty()) empty = false; | 1699 if (!category->is_empty()) empty = false; |
| (...skipping 1200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2900 PageIterator old_iterator_; | 2900 PageIterator old_iterator_; |
| 2901 PageIterator code_iterator_; | 2901 PageIterator code_iterator_; |
| 2902 PageIterator map_iterator_; | 2902 PageIterator map_iterator_; |
| 2903 LargePageIterator lo_iterator_; | 2903 LargePageIterator lo_iterator_; |
| 2904 }; | 2904 }; |
| 2905 | 2905 |
| 2906 } // namespace internal | 2906 } // namespace internal |
| 2907 } // namespace v8 | 2907 } // namespace v8 |
| 2908 | 2908 |
| 2909 #endif // V8_HEAP_SPACES_H_ | 2909 #endif // V8_HEAP_SPACES_H_ |
| OLD | NEW |