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 = 400 * 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 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1568 CHECK(size_ >= 0); | 1570 CHECK(size_ >= 0); |
1569 } | 1571 } |
1570 | 1572 |
1571 // Shrink the space by removing available bytes. Since shrinking is done | 1573 // Shrink the space by removing available bytes. Since shrinking is done |
1572 // during sweeping, bytes have been marked as being in use (part of the size) | 1574 // during sweeping, bytes have been marked as being in use (part of the size) |
1573 // and are hereby freed. | 1575 // and are hereby freed. |
1574 void ShrinkSpace(int size_in_bytes) { | 1576 void ShrinkSpace(int size_in_bytes) { |
1575 capacity_ -= size_in_bytes; | 1577 capacity_ -= size_in_bytes; |
1576 size_ -= size_in_bytes; | 1578 size_ -= size_in_bytes; |
1577 CHECK_GE(size_, 0); | 1579 CHECK_GE(size_, 0); |
1580 CHECK_GE(capacity_, 0); | |
1578 } | 1581 } |
1579 | 1582 |
1580 // Allocate from available bytes (available -> size). | 1583 // Allocate from available bytes (available -> size). |
1581 void AllocateBytes(intptr_t size_in_bytes) { | 1584 void AllocateBytes(intptr_t size_in_bytes) { |
1582 size_ += size_in_bytes; | 1585 size_ += size_in_bytes; |
1583 CHECK_GE(size_, 0); | 1586 CHECK_GE(size_, 0); |
1584 } | 1587 } |
1585 | 1588 |
1586 // Free allocated bytes, making them available (size -> available). | 1589 // Free allocated bytes, making them available (size -> available). |
1587 void DeallocateBytes(intptr_t size_in_bytes) { | 1590 void DeallocateBytes(intptr_t size_in_bytes) { |
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2133 FreeList* free_list() { return &free_list_; } | 2136 FreeList* free_list() { return &free_list_; } |
2134 | 2137 |
2135 base::Mutex* mutex() { return &space_mutex_; } | 2138 base::Mutex* mutex() { return &space_mutex_; } |
2136 | 2139 |
2137 inline void UnlinkFreeListCategories(Page* page); | 2140 inline void UnlinkFreeListCategories(Page* page); |
2138 inline intptr_t RelinkFreeListCategories(Page* page); | 2141 inline intptr_t RelinkFreeListCategories(Page* page); |
2139 | 2142 |
2140 iterator begin() { return iterator(anchor_.next_page()); } | 2143 iterator begin() { return iterator(anchor_.next_page()); } |
2141 iterator end() { return iterator(&anchor_); } | 2144 iterator end() { return iterator(&anchor_); } |
2142 | 2145 |
2146 // Shrink all pages of the space to be exactly the size needed using the | |
2147 // high water mark. | |
Hannes Payer (out of office)
2016/08/10 21:17:35
We only do that for immortal immovable pages.
Michael Lippautz
2016/08/11 09:48:10
Done.
| |
2148 void ShrinkImmortalImmovablePages(); | |
2149 | |
2143 protected: | 2150 protected: |
2144 // PagedSpaces that should be included in snapshots have different, i.e., | 2151 // PagedSpaces that should be included in snapshots have different, i.e., |
2145 // smaller, initial pages. | 2152 // smaller, initial pages. |
2146 virtual bool snapshotable() { return true; } | 2153 virtual bool snapshotable() { return true; } |
2147 | 2154 |
2148 bool HasPages() { return anchor_.next_page() != &anchor_; } | 2155 bool HasPages() { return anchor_.next_page() != &anchor_; } |
2149 | 2156 |
2150 // Cleans up the space, frees all pages in this space except those belonging | 2157 // Cleans up the space, frees all pages in this space except those belonging |
2151 // to the initial chunk, uncommits addresses in the initial chunk. | 2158 // to the initial chunk, uncommits addresses in the initial chunk. |
2152 void TearDown(); | 2159 void TearDown(); |
(...skipping 832 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2985 count = 0; | 2992 count = 0; |
2986 } | 2993 } |
2987 // Must be small, since an iteration is used for lookup. | 2994 // Must be small, since an iteration is used for lookup. |
2988 static const int kMaxComments = 64; | 2995 static const int kMaxComments = 64; |
2989 }; | 2996 }; |
2990 #endif | 2997 #endif |
2991 } // namespace internal | 2998 } // namespace internal |
2992 } // namespace v8 | 2999 } // namespace v8 |
2993 | 3000 |
2994 #endif // V8_HEAP_SPACES_H_ | 3001 #endif // V8_HEAP_SPACES_H_ |
OLD | NEW |