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 | 10 |
(...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
682 (1 << MemoryChunk::POINTERS_TO_HERE_ARE_INTERESTING) | | 682 (1 << MemoryChunk::POINTERS_TO_HERE_ARE_INTERESTING) | |
683 (1 << MemoryChunk::POINTERS_FROM_HERE_ARE_INTERESTING); | 683 (1 << MemoryChunk::POINTERS_FROM_HERE_ARE_INTERESTING); |
684 | 684 |
685 // Maximum object size that gets allocated into regular pages. Objects larger | 685 // Maximum object size that gets allocated into regular pages. Objects larger |
686 // than that size are allocated in large object space and are never moved in | 686 // than that size are allocated in large object space and are never moved in |
687 // memory. This also applies to new space allocation, since objects are never | 687 // memory. This also applies to new space allocation, since objects are never |
688 // migrated from new space to large object space. Takes double alignment into | 688 // migrated from new space to large object space. Takes double alignment into |
689 // account. | 689 // account. |
690 // TODO(hpayer): This limit should be way smaller but we currently have | 690 // TODO(hpayer): This limit should be way smaller but we currently have |
691 // short living objects >256K. | 691 // short living objects >256K. |
692 static const int kMaxRegularHeapObjectSize = 600 * KB; | 692 static const int kMaxRegularHeapObjectSize = 300 * KB; |
693 | 693 |
694 static inline Page* ConvertNewToOld(Page* old_page, PagedSpace* new_owner); | 694 static inline Page* ConvertNewToOld(Page* old_page, PagedSpace* new_owner); |
695 | 695 |
696 // Returns the page containing a given address. The address ranges | 696 // Returns the page containing a given address. The address ranges |
697 // from [page_addr .. page_addr + kPageSize[. This only works if the object | 697 // from [page_addr .. page_addr + kPageSize[. This only works if the object |
698 // is in fact in a page. | 698 // is in fact in a page. |
699 static Page* FromAddress(Address addr) { | 699 static Page* FromAddress(Address addr) { |
700 return reinterpret_cast<Page*>(OffsetFrom(addr) & ~kPageAlignmentMask); | 700 return reinterpret_cast<Page*>(OffsetFrom(addr) & ~kPageAlignmentMask); |
701 } | 701 } |
702 | 702 |
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1263 void ReportStatistics(); | 1263 void ReportStatistics(); |
1264 #endif | 1264 #endif |
1265 | 1265 |
1266 // Returns a MemoryChunk in which the memory region from commit_area_size to | 1266 // Returns a MemoryChunk in which the memory region from commit_area_size to |
1267 // reserve_area_size of the chunk area is reserved but not committed, it | 1267 // reserve_area_size of the chunk area is reserved but not committed, it |
1268 // could be committed later by calling MemoryChunk::CommitArea. | 1268 // could be committed later by calling MemoryChunk::CommitArea. |
1269 MemoryChunk* AllocateChunk(intptr_t reserve_area_size, | 1269 MemoryChunk* AllocateChunk(intptr_t reserve_area_size, |
1270 intptr_t commit_area_size, | 1270 intptr_t commit_area_size, |
1271 Executability executable, Space* space); | 1271 Executability executable, Space* space); |
1272 | 1272 |
| 1273 void ShrinkChunk(MemoryChunk* chunk, size_t bytes_to_shrink); |
| 1274 |
1273 Address ReserveAlignedMemory(size_t requested, size_t alignment, | 1275 Address ReserveAlignedMemory(size_t requested, size_t alignment, |
1274 base::VirtualMemory* controller); | 1276 base::VirtualMemory* controller); |
1275 Address AllocateAlignedMemory(size_t reserve_size, size_t commit_size, | 1277 Address AllocateAlignedMemory(size_t reserve_size, size_t commit_size, |
1276 size_t alignment, Executability executable, | 1278 size_t alignment, Executability executable, |
1277 base::VirtualMemory* controller); | 1279 base::VirtualMemory* controller); |
1278 | 1280 |
1279 bool CommitMemory(Address addr, size_t size, Executability executable); | 1281 bool CommitMemory(Address addr, size_t size, Executability executable); |
1280 | 1282 |
1281 void FreeMemory(base::VirtualMemory* reservation, Executability executable); | 1283 void FreeMemory(base::VirtualMemory* reservation, Executability executable); |
1282 void PartialFreeMemory(MemoryChunk* chunk, Address start_free); | 1284 void PartialFreeMemory(MemoryChunk* chunk, Address start_free); |
(...skipping 850 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2133 FreeList* free_list() { return &free_list_; } | 2135 FreeList* free_list() { return &free_list_; } |
2134 | 2136 |
2135 base::Mutex* mutex() { return &space_mutex_; } | 2137 base::Mutex* mutex() { return &space_mutex_; } |
2136 | 2138 |
2137 inline void UnlinkFreeListCategories(Page* page); | 2139 inline void UnlinkFreeListCategories(Page* page); |
2138 inline intptr_t RelinkFreeListCategories(Page* page); | 2140 inline intptr_t RelinkFreeListCategories(Page* page); |
2139 | 2141 |
2140 iterator begin() { return iterator(anchor_.next_page()); } | 2142 iterator begin() { return iterator(anchor_.next_page()); } |
2141 iterator end() { return iterator(&anchor_); } | 2143 iterator end() { return iterator(&anchor_); } |
2142 | 2144 |
| 2145 // Shrink all pages of the space to be exactly the size needed using the |
| 2146 // high water mark. |
| 2147 void ShrinkPagesToHighWaterMark(); |
| 2148 |
2143 protected: | 2149 protected: |
2144 // PagedSpaces that should be included in snapshots have different, i.e., | 2150 // PagedSpaces that should be included in snapshots have different, i.e., |
2145 // smaller, initial pages. | 2151 // smaller, initial pages. |
2146 virtual bool snapshotable() { return true; } | 2152 virtual bool snapshotable() { return true; } |
2147 | 2153 |
2148 bool HasPages() { return anchor_.next_page() != &anchor_; } | 2154 bool HasPages() { return anchor_.next_page() != &anchor_; } |
2149 | 2155 |
2150 // Cleans up the space, frees all pages in this space except those belonging | 2156 // Cleans up the space, frees all pages in this space except those belonging |
2151 // to the initial chunk, uncommits addresses in the initial chunk. | 2157 // to the initial chunk, uncommits addresses in the initial chunk. |
2152 void TearDown(); | 2158 void TearDown(); |
(...skipping 832 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2985 count = 0; | 2991 count = 0; |
2986 } | 2992 } |
2987 // Must be small, since an iteration is used for lookup. | 2993 // Must be small, since an iteration is used for lookup. |
2988 static const int kMaxComments = 64; | 2994 static const int kMaxComments = 64; |
2989 }; | 2995 }; |
2990 #endif | 2996 #endif |
2991 } // namespace internal | 2997 } // namespace internal |
2992 } // namespace v8 | 2998 } // namespace v8 |
2993 | 2999 |
2994 #endif // V8_HEAP_SPACES_H_ | 3000 #endif // V8_HEAP_SPACES_H_ |
OLD | NEW |