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 "src/allocation.h" | 8 #include "src/allocation.h" |
9 #include "src/base/atomicops.h" | 9 #include "src/base/atomicops.h" |
10 #include "src/base/bits.h" | 10 #include "src/base/bits.h" |
(...skipping 824 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
835 // Identity used in error reporting. | 835 // Identity used in error reporting. |
836 AllocationSpace identity() { return id_; } | 836 AllocationSpace identity() { return id_; } |
837 | 837 |
838 // Returns allocated size. | 838 // Returns allocated size. |
839 virtual intptr_t Size() = 0; | 839 virtual intptr_t Size() = 0; |
840 | 840 |
841 // Returns size of objects. Can differ from the allocated size | 841 // Returns size of objects. Can differ from the allocated size |
842 // (e.g. see LargeObjectSpace). | 842 // (e.g. see LargeObjectSpace). |
843 virtual intptr_t SizeOfObjects() { return Size(); } | 843 virtual intptr_t SizeOfObjects() { return Size(); } |
844 | 844 |
| 845 // Return the total amount of memory committed for new space. |
| 846 virtual intptr_t CommittedMemory() = 0; |
| 847 |
| 848 // Approximate amount of physical memory committed for this space. |
| 849 virtual size_t CommittedPhysicalMemory() = 0; |
| 850 |
| 851 // Return the available bytes without growing. |
| 852 virtual intptr_t Available() = 0; |
| 853 |
845 virtual int RoundSizeDownToObjectAlignment(int size) { | 854 virtual int RoundSizeDownToObjectAlignment(int size) { |
846 if (id_ == CODE_SPACE) { | 855 if (id_ == CODE_SPACE) { |
847 return RoundDown(size, kCodeAlignment); | 856 return RoundDown(size, kCodeAlignment); |
848 } else { | 857 } else { |
849 return RoundDown(size, kPointerSize); | 858 return RoundDown(size, kPointerSize); |
850 } | 859 } |
851 } | 860 } |
852 | 861 |
853 #ifdef DEBUG | 862 #ifdef DEBUG |
854 virtual void Print() = 0; | 863 virtual void Print() = 0; |
(...skipping 822 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1677 void RepairFreeListsAfterDeserialization(); | 1686 void RepairFreeListsAfterDeserialization(); |
1678 | 1687 |
1679 // Prepares for a mark-compact GC. | 1688 // Prepares for a mark-compact GC. |
1680 void PrepareForMarkCompact(); | 1689 void PrepareForMarkCompact(); |
1681 | 1690 |
1682 // Current capacity without growing (Size() + Available()). | 1691 // Current capacity without growing (Size() + Available()). |
1683 intptr_t Capacity() { return accounting_stats_.Capacity(); } | 1692 intptr_t Capacity() { return accounting_stats_.Capacity(); } |
1684 | 1693 |
1685 // Total amount of memory committed for this space. For paged | 1694 // Total amount of memory committed for this space. For paged |
1686 // spaces this equals the capacity. | 1695 // spaces this equals the capacity. |
1687 intptr_t CommittedMemory() { return Capacity(); } | 1696 intptr_t CommittedMemory() override { return Capacity(); } |
1688 | 1697 |
1689 // The maximum amount of memory ever committed for this space. | 1698 // The maximum amount of memory ever committed for this space. |
1690 intptr_t MaximumCommittedMemory() { return accounting_stats_.MaxCapacity(); } | 1699 intptr_t MaximumCommittedMemory() { return accounting_stats_.MaxCapacity(); } |
1691 | 1700 |
1692 // Approximate amount of physical memory committed for this space. | 1701 // Approximate amount of physical memory committed for this space. |
1693 size_t CommittedPhysicalMemory(); | 1702 size_t CommittedPhysicalMemory() override; |
1694 | 1703 |
1695 struct SizeStats { | 1704 struct SizeStats { |
1696 intptr_t Total() { | 1705 intptr_t Total() { |
1697 return small_size_ + medium_size_ + large_size_ + huge_size_; | 1706 return small_size_ + medium_size_ + large_size_ + huge_size_; |
1698 } | 1707 } |
1699 | 1708 |
1700 intptr_t small_size_; | 1709 intptr_t small_size_; |
1701 intptr_t medium_size_; | 1710 intptr_t medium_size_; |
1702 intptr_t large_size_; | 1711 intptr_t large_size_; |
1703 intptr_t huge_size_; | 1712 intptr_t huge_size_; |
(...skipping 14 matching lines...) Expand all Loading... |
1718 | 1727 |
1719 // Increases the number of available bytes of that space. | 1728 // Increases the number of available bytes of that space. |
1720 void AddToAccountingStats(intptr_t bytes) { | 1729 void AddToAccountingStats(intptr_t bytes) { |
1721 accounting_stats_.DeallocateBytes(bytes); | 1730 accounting_stats_.DeallocateBytes(bytes); |
1722 } | 1731 } |
1723 | 1732 |
1724 // Available bytes without growing. These are the bytes on the free list. | 1733 // Available bytes without growing. These are the bytes on the free list. |
1725 // The bytes in the linear allocation area are not included in this total | 1734 // The bytes in the linear allocation area are not included in this total |
1726 // because updating the stats would slow down allocation. New pages are | 1735 // because updating the stats would slow down allocation. New pages are |
1727 // immediately added to the free list so they show up here. | 1736 // immediately added to the free list so they show up here. |
1728 intptr_t Available() { return free_list_.available(); } | 1737 intptr_t Available() override { return free_list_.available(); } |
1729 | 1738 |
1730 // Allocated bytes in this space. Garbage bytes that were not found due to | 1739 // Allocated bytes in this space. Garbage bytes that were not found due to |
1731 // concurrent sweeping are counted as being allocated! The bytes in the | 1740 // concurrent sweeping are counted as being allocated! The bytes in the |
1732 // current linear allocation area (between top and limit) are also counted | 1741 // current linear allocation area (between top and limit) are also counted |
1733 // here. | 1742 // here. |
1734 virtual intptr_t Size() { return accounting_stats_.Size(); } | 1743 intptr_t Size() override { return accounting_stats_.Size(); } |
1735 | 1744 |
1736 // As size, but the bytes in lazily swept pages are estimated and the bytes | 1745 // As size, but the bytes in lazily swept pages are estimated and the bytes |
1737 // in the current linear allocation area are not included. | 1746 // in the current linear allocation area are not included. |
1738 virtual intptr_t SizeOfObjects(); | 1747 intptr_t SizeOfObjects() override; |
1739 | 1748 |
1740 // Wasted bytes in this space. These are just the bytes that were thrown away | 1749 // Wasted bytes in this space. These are just the bytes that were thrown away |
1741 // due to being too small to use for allocation. They do not include the | 1750 // due to being too small to use for allocation. They do not include the |
1742 // free bytes that were not found at all due to lazy sweeping. | 1751 // free bytes that were not found at all due to lazy sweeping. |
1743 virtual intptr_t Waste() { return accounting_stats_.Waste(); } | 1752 virtual intptr_t Waste() { return accounting_stats_.Waste(); } |
1744 | 1753 |
1745 // Returns the allocation pointer in this space. | 1754 // Returns the allocation pointer in this space. |
1746 Address top() { return allocation_info_.top(); } | 1755 Address top() { return allocation_info_.top(); } |
1747 Address limit() { return allocation_info_.limit(); } | 1756 Address limit() { return allocation_info_.limit(); } |
1748 | 1757 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1797 // Verify integrity of this space. | 1806 // Verify integrity of this space. |
1798 virtual void Verify(ObjectVisitor* visitor); | 1807 virtual void Verify(ObjectVisitor* visitor); |
1799 | 1808 |
1800 // Overridden by subclasses to verify space-specific object | 1809 // Overridden by subclasses to verify space-specific object |
1801 // properties (e.g., only maps or free-list nodes are in map space). | 1810 // properties (e.g., only maps or free-list nodes are in map space). |
1802 virtual void VerifyObject(HeapObject* obj) {} | 1811 virtual void VerifyObject(HeapObject* obj) {} |
1803 #endif | 1812 #endif |
1804 | 1813 |
1805 #ifdef DEBUG | 1814 #ifdef DEBUG |
1806 // Print meta info and objects in this space. | 1815 // Print meta info and objects in this space. |
1807 virtual void Print(); | 1816 void Print() override; |
1808 | 1817 |
1809 // Reports statistics for the space | 1818 // Reports statistics for the space |
1810 void ReportStatistics(); | 1819 void ReportStatistics(); |
1811 | 1820 |
1812 // Report code object related statistics | 1821 // Report code object related statistics |
1813 void CollectCodeStatistics(); | 1822 void CollectCodeStatistics(); |
1814 static void ReportCodeStatistics(Isolate* isolate); | 1823 static void ReportCodeStatistics(Isolate* isolate); |
1815 static void ResetCodeStatistics(Isolate* isolate); | 1824 static void ResetCodeStatistics(Isolate* isolate); |
1816 #endif | 1825 #endif |
1817 | 1826 |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2122 reinterpret_cast<uintptr_t>(start_); | 2131 reinterpret_cast<uintptr_t>(start_); |
2123 } | 2132 } |
2124 | 2133 |
2125 // True if the object is a heap object in the address range of this | 2134 // True if the object is a heap object in the address range of this |
2126 // semispace (not necessarily below the allocation pointer). | 2135 // semispace (not necessarily below the allocation pointer). |
2127 bool Contains(Object* o) { | 2136 bool Contains(Object* o) { |
2128 return (reinterpret_cast<uintptr_t>(o) & object_mask_) == object_expected_; | 2137 return (reinterpret_cast<uintptr_t>(o) & object_mask_) == object_expected_; |
2129 } | 2138 } |
2130 | 2139 |
2131 // If we don't have these here then SemiSpace will be abstract. However | 2140 // If we don't have these here then SemiSpace will be abstract. However |
2132 // they should never be called. | 2141 // they should never be called: |
2133 virtual intptr_t Size() { | 2142 |
| 2143 intptr_t Size() override { |
2134 UNREACHABLE(); | 2144 UNREACHABLE(); |
2135 return 0; | 2145 return 0; |
2136 } | 2146 } |
2137 | 2147 |
| 2148 intptr_t SizeOfObjects() override { return Size(); } |
| 2149 |
| 2150 intptr_t CommittedMemory() override { |
| 2151 UNREACHABLE(); |
| 2152 return 0; |
| 2153 } |
| 2154 |
| 2155 intptr_t Available() override { |
| 2156 UNREACHABLE(); |
| 2157 return 0; |
| 2158 } |
| 2159 |
| 2160 |
2138 bool is_committed() { return committed_; } | 2161 bool is_committed() { return committed_; } |
2139 bool Commit(); | 2162 bool Commit(); |
2140 bool Uncommit(); | 2163 bool Uncommit(); |
2141 | 2164 |
2142 NewSpacePage* first_page() { return anchor_.next_page(); } | 2165 NewSpacePage* first_page() { return anchor_.next_page(); } |
2143 NewSpacePage* current_page() { return current_page_; } | 2166 NewSpacePage* current_page() { return current_page_; } |
2144 | 2167 |
2145 #ifdef VERIFY_HEAP | 2168 #ifdef VERIFY_HEAP |
2146 virtual void Verify(); | 2169 virtual void Verify(); |
2147 #endif | 2170 #endif |
2148 | 2171 |
2149 #ifdef DEBUG | 2172 #ifdef DEBUG |
2150 virtual void Print(); | 2173 void Print() override; |
2151 // Validate a range of of addresses in a SemiSpace. | 2174 // Validate a range of of addresses in a SemiSpace. |
2152 // The "from" address must be on a page prior to the "to" address, | 2175 // The "from" address must be on a page prior to the "to" address, |
2153 // in the linked page order, or it must be earlier on the same page. | 2176 // in the linked page order, or it must be earlier on the same page. |
2154 static void AssertValidRange(Address from, Address to); | 2177 static void AssertValidRange(Address from, Address to); |
2155 #else | 2178 #else |
2156 // Do nothing. | 2179 // Do nothing. |
2157 inline static void AssertValidRange(Address from, Address to) {} | 2180 inline static void AssertValidRange(Address from, Address to) {} |
2158 #endif | 2181 #endif |
2159 | 2182 |
2160 // Returns the current total capacity of the semispace. | 2183 // Returns the current total capacity of the semispace. |
2161 int TotalCapacity() { return total_capacity_; } | 2184 int TotalCapacity() { return total_capacity_; } |
2162 | 2185 |
2163 // Returns the target for total capacity of the semispace. | 2186 // Returns the target for total capacity of the semispace. |
2164 int TargetCapacity() { return target_capacity_; } | 2187 int TargetCapacity() { return target_capacity_; } |
2165 | 2188 |
2166 // Returns the maximum total capacity of the semispace. | 2189 // Returns the maximum total capacity of the semispace. |
2167 int MaximumTotalCapacity() { return maximum_total_capacity_; } | 2190 int MaximumTotalCapacity() { return maximum_total_capacity_; } |
2168 | 2191 |
2169 // Returns the initial capacity of the semispace. | 2192 // Returns the initial capacity of the semispace. |
2170 int InitialTotalCapacity() { return initial_total_capacity_; } | 2193 int InitialTotalCapacity() { return initial_total_capacity_; } |
2171 | 2194 |
2172 SemiSpaceId id() { return id_; } | 2195 SemiSpaceId id() { return id_; } |
2173 | 2196 |
2174 static void Swap(SemiSpace* from, SemiSpace* to); | 2197 static void Swap(SemiSpace* from, SemiSpace* to); |
2175 | 2198 |
2176 // Returns the maximum amount of memory ever committed by the semi space. | 2199 // Returns the maximum amount of memory ever committed by the semi space. |
2177 size_t MaximumCommittedMemory() { return maximum_committed_; } | 2200 size_t MaximumCommittedMemory() { return maximum_committed_; } |
2178 | 2201 |
2179 // Approximate amount of physical memory committed for this space. | 2202 // Approximate amount of physical memory committed for this space. |
2180 size_t CommittedPhysicalMemory(); | 2203 size_t CommittedPhysicalMemory() override; |
2181 | 2204 |
2182 private: | 2205 private: |
2183 // Flips the semispace between being from-space and to-space. | 2206 // Flips the semispace between being from-space and to-space. |
2184 // Copies the flags into the masked positions on all pages in the space. | 2207 // Copies the flags into the masked positions on all pages in the space. |
2185 void FlipPages(intptr_t flags, intptr_t flag_mask); | 2208 void FlipPages(intptr_t flags, intptr_t flag_mask); |
2186 | 2209 |
2187 // Updates Capacity and MaximumCommitted based on new capacity. | 2210 // Updates Capacity and MaximumCommitted based on new capacity. |
2188 void SetCapacity(int new_capacity); | 2211 void SetCapacity(int new_capacity); |
2189 | 2212 |
2190 NewSpacePage* anchor() { return &anchor_; } | 2213 NewSpacePage* anchor() { return &anchor_; } |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2349 return (reinterpret_cast<uintptr_t>(a) & address_mask_) == | 2372 return (reinterpret_cast<uintptr_t>(a) & address_mask_) == |
2350 reinterpret_cast<uintptr_t>(start_); | 2373 reinterpret_cast<uintptr_t>(start_); |
2351 } | 2374 } |
2352 | 2375 |
2353 bool Contains(Object* o) { | 2376 bool Contains(Object* o) { |
2354 Address a = reinterpret_cast<Address>(o); | 2377 Address a = reinterpret_cast<Address>(o); |
2355 return (reinterpret_cast<uintptr_t>(a) & object_mask_) == object_expected_; | 2378 return (reinterpret_cast<uintptr_t>(a) & object_mask_) == object_expected_; |
2356 } | 2379 } |
2357 | 2380 |
2358 // Return the allocated bytes in the active semispace. | 2381 // Return the allocated bytes in the active semispace. |
2359 virtual intptr_t Size() { | 2382 intptr_t Size() override { |
2360 return pages_used_ * NewSpacePage::kAreaSize + | 2383 return pages_used_ * NewSpacePage::kAreaSize + |
2361 static_cast<int>(top() - to_space_.page_low()); | 2384 static_cast<int>(top() - to_space_.page_low()); |
2362 } | 2385 } |
2363 | 2386 |
2364 // The same, but returning an int. We have to have the one that returns | 2387 // The same, but returning an int. We have to have the one that returns |
2365 // intptr_t because it is inherited, but if we know we are dealing with the | 2388 // intptr_t because it is inherited, but if we know we are dealing with the |
2366 // new space, which can't get as big as the other spaces then this is useful: | 2389 // new space, which can't get as big as the other spaces then this is useful: |
2367 int SizeAsInt() { return static_cast<int>(Size()); } | 2390 int SizeAsInt() { return static_cast<int>(Size()); } |
2368 | 2391 |
2369 // Return the allocatable capacity of a semispace. | 2392 // Return the allocatable capacity of a semispace. |
2370 intptr_t Capacity() { | 2393 intptr_t Capacity() { |
2371 SLOW_DCHECK(to_space_.TotalCapacity() == from_space_.TotalCapacity()); | 2394 SLOW_DCHECK(to_space_.TotalCapacity() == from_space_.TotalCapacity()); |
2372 return (to_space_.TotalCapacity() / Page::kPageSize) * | 2395 return (to_space_.TotalCapacity() / Page::kPageSize) * |
2373 NewSpacePage::kAreaSize; | 2396 NewSpacePage::kAreaSize; |
2374 } | 2397 } |
2375 | 2398 |
2376 // Return the current size of a semispace, allocatable and non-allocatable | 2399 // Return the current size of a semispace, allocatable and non-allocatable |
2377 // memory. | 2400 // memory. |
2378 intptr_t TotalCapacity() { | 2401 intptr_t TotalCapacity() { |
2379 DCHECK(to_space_.TotalCapacity() == from_space_.TotalCapacity()); | 2402 DCHECK(to_space_.TotalCapacity() == from_space_.TotalCapacity()); |
2380 return to_space_.TotalCapacity(); | 2403 return to_space_.TotalCapacity(); |
2381 } | 2404 } |
2382 | 2405 |
2383 // Return the total amount of memory committed for new space. | 2406 // Return the total amount of memory committed for new space. |
2384 intptr_t CommittedMemory() { | 2407 intptr_t CommittedMemory() override { |
2385 if (from_space_.is_committed()) return 2 * Capacity(); | 2408 if (from_space_.is_committed()) return 2 * Capacity(); |
2386 return TotalCapacity(); | 2409 return TotalCapacity(); |
2387 } | 2410 } |
2388 | 2411 |
2389 // Return the total amount of memory committed for new space. | 2412 // Return the total amount of memory committed for new space. |
2390 intptr_t MaximumCommittedMemory() { | 2413 intptr_t MaximumCommittedMemory() { |
2391 return to_space_.MaximumCommittedMemory() + | 2414 return to_space_.MaximumCommittedMemory() + |
2392 from_space_.MaximumCommittedMemory(); | 2415 from_space_.MaximumCommittedMemory(); |
2393 } | 2416 } |
2394 | 2417 |
2395 // Approximate amount of physical memory committed for this space. | 2418 // Approximate amount of physical memory committed for this space. |
2396 size_t CommittedPhysicalMemory(); | 2419 size_t CommittedPhysicalMemory() override; |
2397 | 2420 |
2398 // Return the available bytes without growing. | 2421 // Return the available bytes without growing. |
2399 intptr_t Available() { return Capacity() - Size(); } | 2422 intptr_t Available() override { return Capacity() - Size(); } |
2400 | 2423 |
2401 // Return the maximum capacity of a semispace. | 2424 // Return the maximum capacity of a semispace. |
2402 int MaximumCapacity() { | 2425 int MaximumCapacity() { |
2403 DCHECK(to_space_.MaximumTotalCapacity() == | 2426 DCHECK(to_space_.MaximumTotalCapacity() == |
2404 from_space_.MaximumTotalCapacity()); | 2427 from_space_.MaximumTotalCapacity()); |
2405 return to_space_.MaximumTotalCapacity(); | 2428 return to_space_.MaximumTotalCapacity(); |
2406 } | 2429 } |
2407 | 2430 |
2408 bool IsAtMaximumCapacity() { return TotalCapacity() == MaximumCapacity(); } | 2431 bool IsAtMaximumCapacity() { return TotalCapacity() == MaximumCapacity(); } |
2409 | 2432 |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2506 // if successful. | 2529 // if successful. |
2507 bool AddFreshPage(); | 2530 bool AddFreshPage(); |
2508 | 2531 |
2509 #ifdef VERIFY_HEAP | 2532 #ifdef VERIFY_HEAP |
2510 // Verify the active semispace. | 2533 // Verify the active semispace. |
2511 virtual void Verify(); | 2534 virtual void Verify(); |
2512 #endif | 2535 #endif |
2513 | 2536 |
2514 #ifdef DEBUG | 2537 #ifdef DEBUG |
2515 // Print the active semispace. | 2538 // Print the active semispace. |
2516 virtual void Print() { to_space_.Print(); } | 2539 void Print() override { to_space_.Print(); } |
2517 #endif | 2540 #endif |
2518 | 2541 |
2519 // Iterates the active semispace to collect statistics. | 2542 // Iterates the active semispace to collect statistics. |
2520 void CollectStatistics(); | 2543 void CollectStatistics(); |
2521 // Reports previously collected statistics of the active semispace. | 2544 // Reports previously collected statistics of the active semispace. |
2522 void ReportStatistics(); | 2545 void ReportStatistics(); |
2523 // Clears previously collected statistics. | 2546 // Clears previously collected statistics. |
2524 void ClearHistograms(); | 2547 void ClearHistograms(); |
2525 | 2548 |
2526 // Record the allocation or promotion of a heap object. Note that we don't | 2549 // Record the allocation or promotion of a heap object. Note that we don't |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2677 } | 2700 } |
2678 | 2701 |
2679 // Shared implementation of AllocateRaw, AllocateRawCode and | 2702 // Shared implementation of AllocateRaw, AllocateRawCode and |
2680 // AllocateRawFixedArray. | 2703 // AllocateRawFixedArray. |
2681 MUST_USE_RESULT AllocationResult | 2704 MUST_USE_RESULT AllocationResult |
2682 AllocateRaw(int object_size, Executability executable); | 2705 AllocateRaw(int object_size, Executability executable); |
2683 | 2706 |
2684 bool CanAllocateSize(int size) { return Size() + size <= max_capacity_; } | 2707 bool CanAllocateSize(int size) { return Size() + size <= max_capacity_; } |
2685 | 2708 |
2686 // Available bytes for objects in this space. | 2709 // Available bytes for objects in this space. |
2687 inline intptr_t Available(); | 2710 inline intptr_t Available() override; |
2688 | 2711 |
2689 virtual intptr_t Size() { return size_; } | 2712 intptr_t Size() override { return size_; } |
2690 | 2713 |
2691 virtual intptr_t SizeOfObjects() { return objects_size_; } | 2714 intptr_t SizeOfObjects() override { return objects_size_; } |
2692 | 2715 |
2693 intptr_t MaximumCommittedMemory() { return maximum_committed_; } | 2716 intptr_t MaximumCommittedMemory() { return maximum_committed_; } |
2694 | 2717 |
2695 intptr_t CommittedMemory() { return Size(); } | 2718 intptr_t CommittedMemory() override { return Size(); } |
2696 | 2719 |
2697 // Approximate amount of physical memory committed for this space. | 2720 // Approximate amount of physical memory committed for this space. |
2698 size_t CommittedPhysicalMemory(); | 2721 size_t CommittedPhysicalMemory() override; |
2699 | 2722 |
2700 int PageCount() { return page_count_; } | 2723 int PageCount() { return page_count_; } |
2701 | 2724 |
2702 // Finds an object for a given address, returns a Smi if it is not found. | 2725 // Finds an object for a given address, returns a Smi if it is not found. |
2703 // The function iterates through all objects in this space, may be slow. | 2726 // The function iterates through all objects in this space, may be slow. |
2704 Object* FindObject(Address a); | 2727 Object* FindObject(Address a); |
2705 | 2728 |
2706 // Finds a large object page containing the given address, returns NULL | 2729 // Finds a large object page containing the given address, returns NULL |
2707 // if such a page doesn't exist. | 2730 // if such a page doesn't exist. |
2708 LargePage* FindPage(Address a); | 2731 LargePage* FindPage(Address a); |
2709 | 2732 |
2710 // Frees unmarked objects. | 2733 // Frees unmarked objects. |
2711 void FreeUnmarkedObjects(); | 2734 void FreeUnmarkedObjects(); |
2712 | 2735 |
2713 // Checks whether a heap object is in this space; O(1). | 2736 // Checks whether a heap object is in this space; O(1). |
2714 bool Contains(HeapObject* obj); | 2737 bool Contains(HeapObject* obj); |
2715 | 2738 |
2716 // Checks whether the space is empty. | 2739 // Checks whether the space is empty. |
2717 bool IsEmpty() { return first_page_ == NULL; } | 2740 bool IsEmpty() { return first_page_ == NULL; } |
2718 | 2741 |
2719 LargePage* first_page() { return first_page_; } | 2742 LargePage* first_page() { return first_page_; } |
2720 | 2743 |
2721 #ifdef VERIFY_HEAP | 2744 #ifdef VERIFY_HEAP |
2722 virtual void Verify(); | 2745 virtual void Verify(); |
2723 #endif | 2746 #endif |
2724 | 2747 |
2725 #ifdef DEBUG | 2748 #ifdef DEBUG |
2726 virtual void Print(); | 2749 void Print() override; |
2727 void ReportStatistics(); | 2750 void ReportStatistics(); |
2728 void CollectCodeStatistics(); | 2751 void CollectCodeStatistics(); |
2729 #endif | 2752 #endif |
2730 // Checks whether an address is in the object area in this space. It | 2753 // Checks whether an address is in the object area in this space. It |
2731 // iterates all objects in the space. May be slow. | 2754 // iterates all objects in the space. May be slow. |
2732 bool SlowContains(Address addr) { return FindObject(addr)->IsHeapObject(); } | 2755 bool SlowContains(Address addr) { return FindObject(addr)->IsHeapObject(); } |
2733 | 2756 |
2734 private: | 2757 private: |
2735 intptr_t max_capacity_; | 2758 intptr_t max_capacity_; |
2736 intptr_t maximum_committed_; | 2759 intptr_t maximum_committed_; |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2832 count = 0; | 2855 count = 0; |
2833 } | 2856 } |
2834 // Must be small, since an iteration is used for lookup. | 2857 // Must be small, since an iteration is used for lookup. |
2835 static const int kMaxComments = 64; | 2858 static const int kMaxComments = 64; |
2836 }; | 2859 }; |
2837 #endif | 2860 #endif |
2838 } | 2861 } |
2839 } // namespace v8::internal | 2862 } // namespace v8::internal |
2840 | 2863 |
2841 #endif // V8_HEAP_SPACES_H_ | 2864 #endif // V8_HEAP_SPACES_H_ |
OLD | NEW |