Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(644)

Side by Side Diff: src/heap/spaces.h

Issue 2232653003: Reland of "[heap] Switch to 500k pages" (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Switch back to using the high water mark. Also: dont sweep immortal immovable pages Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 class MemoryChunk { 227 class MemoryChunk {
228 public: 228 public:
229 enum MemoryChunkFlags { 229 enum MemoryChunkFlags {
230 IS_EXECUTABLE, 230 IS_EXECUTABLE,
231 POINTERS_TO_HERE_ARE_INTERESTING, 231 POINTERS_TO_HERE_ARE_INTERESTING,
232 POINTERS_FROM_HERE_ARE_INTERESTING, 232 POINTERS_FROM_HERE_ARE_INTERESTING,
233 IN_FROM_SPACE, // Mutually exclusive with IN_TO_SPACE. 233 IN_FROM_SPACE, // Mutually exclusive with IN_TO_SPACE.
234 IN_TO_SPACE, // All pages in new space has one of these two set. 234 IN_TO_SPACE, // All pages in new space has one of these two set.
235 NEW_SPACE_BELOW_AGE_MARK, 235 NEW_SPACE_BELOW_AGE_MARK,
236 EVACUATION_CANDIDATE, 236 EVACUATION_CANDIDATE,
237 NEVER_EVACUATE, // May contain immortal immutables. 237
238 // |NEVER_EVACUATE|: A page tagged with this flag will never be selected
239 // for evacuation. Typically used for immortal immovable pages.
240 NEVER_EVACUATE,
241
242 // |NEVER_SWEEP|: A page tagged with this flag will be ignored by the
243 // sweeper. The memory will always be accounted for as allocated. Typically
244 // used for immortal immovable pages.
245 NEVER_SWEEP,
238 246
239 // Large objects can have a progress bar in their page header. These object 247 // Large objects can have a progress bar in their page header. These object
240 // are scanned in increments and will be kept black while being scanned. 248 // are scanned in increments and will be kept black while being scanned.
241 // Even if the mutator writes to them they will be kept black and a white 249 // Even if the mutator writes to them they will be kept black and a white
242 // to grey transition is performed in the value. 250 // to grey transition is performed in the value.
243 HAS_PROGRESS_BAR, 251 HAS_PROGRESS_BAR,
244 252
245 // |PAGE_NEW_OLD_PROMOTION|: A page tagged with this flag has been promoted 253 // |PAGE_NEW_OLD_PROMOTION|: A page tagged with this flag has been promoted
246 // from new to old space during evacuation. 254 // from new to old space during evacuation.
247 PAGE_NEW_OLD_PROMOTION, 255 PAGE_NEW_OLD_PROMOTION,
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 (1 << MemoryChunk::POINTERS_TO_HERE_ARE_INTERESTING) | 690 (1 << MemoryChunk::POINTERS_TO_HERE_ARE_INTERESTING) |
683 (1 << MemoryChunk::POINTERS_FROM_HERE_ARE_INTERESTING); 691 (1 << MemoryChunk::POINTERS_FROM_HERE_ARE_INTERESTING);
684 692
685 // Maximum object size that gets allocated into regular pages. Objects larger 693 // 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 694 // 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 695 // 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 696 // migrated from new space to large object space. Takes double alignment into
689 // account. 697 // account.
690 // TODO(hpayer): This limit should be way smaller but we currently have 698 // TODO(hpayer): This limit should be way smaller but we currently have
691 // short living objects >256K. 699 // short living objects >256K.
692 static const int kMaxRegularHeapObjectSize = 600 * KB; 700 static const int kMaxRegularHeapObjectSize = 400 * KB;
693 701
694 static inline Page* ConvertNewToOld(Page* old_page, PagedSpace* new_owner); 702 static inline Page* ConvertNewToOld(Page* old_page, PagedSpace* new_owner);
695 703
696 // Returns the page containing a given address. The address ranges 704 // Returns the page containing a given address. The address ranges
697 // from [page_addr .. page_addr + kPageSize[. This only works if the object 705 // from [page_addr .. page_addr + kPageSize[. This only works if the object
698 // is in fact in a page. 706 // is in fact in a page.
699 static Page* FromAddress(Address addr) { 707 static Page* FromAddress(Address addr) {
700 return reinterpret_cast<Page*>(OffsetFrom(addr) & ~kPageAlignmentMask); 708 return reinterpret_cast<Page*>(OffsetFrom(addr) & ~kPageAlignmentMask);
701 } 709 }
702 710
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after
1263 void ReportStatistics(); 1271 void ReportStatistics();
1264 #endif 1272 #endif
1265 1273
1266 // Returns a MemoryChunk in which the memory region from commit_area_size to 1274 // 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 1275 // reserve_area_size of the chunk area is reserved but not committed, it
1268 // could be committed later by calling MemoryChunk::CommitArea. 1276 // could be committed later by calling MemoryChunk::CommitArea.
1269 MemoryChunk* AllocateChunk(intptr_t reserve_area_size, 1277 MemoryChunk* AllocateChunk(intptr_t reserve_area_size,
1270 intptr_t commit_area_size, 1278 intptr_t commit_area_size,
1271 Executability executable, Space* space); 1279 Executability executable, Space* space);
1272 1280
1281 void ShrinkChunk(MemoryChunk* chunk, size_t bytes_to_shrink);
1282
1273 Address ReserveAlignedMemory(size_t requested, size_t alignment, 1283 Address ReserveAlignedMemory(size_t requested, size_t alignment,
1274 base::VirtualMemory* controller); 1284 base::VirtualMemory* controller);
1275 Address AllocateAlignedMemory(size_t reserve_size, size_t commit_size, 1285 Address AllocateAlignedMemory(size_t reserve_size, size_t commit_size,
1276 size_t alignment, Executability executable, 1286 size_t alignment, Executability executable,
1277 base::VirtualMemory* controller); 1287 base::VirtualMemory* controller);
1278 1288
1279 bool CommitMemory(Address addr, size_t size, Executability executable); 1289 bool CommitMemory(Address addr, size_t size, Executability executable);
1280 1290
1281 void FreeMemory(base::VirtualMemory* reservation, Executability executable); 1291 void FreeMemory(base::VirtualMemory* reservation, Executability executable);
1282 void PartialFreeMemory(MemoryChunk* chunk, Address start_free); 1292 void PartialFreeMemory(MemoryChunk* chunk, Address start_free);
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
1568 CHECK(size_ >= 0); 1578 CHECK(size_ >= 0);
1569 } 1579 }
1570 1580
1571 // Shrink the space by removing available bytes. Since shrinking is done 1581 // 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) 1582 // during sweeping, bytes have been marked as being in use (part of the size)
1573 // and are hereby freed. 1583 // and are hereby freed.
1574 void ShrinkSpace(int size_in_bytes) { 1584 void ShrinkSpace(int size_in_bytes) {
1575 capacity_ -= size_in_bytes; 1585 capacity_ -= size_in_bytes;
1576 size_ -= size_in_bytes; 1586 size_ -= size_in_bytes;
1577 CHECK_GE(size_, 0); 1587 CHECK_GE(size_, 0);
1588 CHECK_GE(capacity_, 0);
1578 } 1589 }
1579 1590
1580 // Allocate from available bytes (available -> size). 1591 // Allocate from available bytes (available -> size).
1581 void AllocateBytes(intptr_t size_in_bytes) { 1592 void AllocateBytes(intptr_t size_in_bytes) {
1582 size_ += size_in_bytes; 1593 size_ += size_in_bytes;
1583 CHECK_GE(size_, 0); 1594 CHECK_GE(size_, 0);
1584 } 1595 }
1585 1596
1586 // Free allocated bytes, making them available (size -> available). 1597 // Free allocated bytes, making them available (size -> available).
1587 void DeallocateBytes(intptr_t size_in_bytes) { 1598 void DeallocateBytes(intptr_t size_in_bytes) {
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after
2133 FreeList* free_list() { return &free_list_; } 2144 FreeList* free_list() { return &free_list_; }
2134 2145
2135 base::Mutex* mutex() { return &space_mutex_; } 2146 base::Mutex* mutex() { return &space_mutex_; }
2136 2147
2137 inline void UnlinkFreeListCategories(Page* page); 2148 inline void UnlinkFreeListCategories(Page* page);
2138 inline intptr_t RelinkFreeListCategories(Page* page); 2149 inline intptr_t RelinkFreeListCategories(Page* page);
2139 2150
2140 iterator begin() { return iterator(anchor_.next_page()); } 2151 iterator begin() { return iterator(anchor_.next_page()); }
2141 iterator end() { return iterator(&anchor_); } 2152 iterator end() { return iterator(&anchor_); }
2142 2153
2154 // Shrink immortal immovable pages of the space to be exactly the size needed
2155 // using the high water mark.
2156 void ShrinkImmortalImmovablePages();
2157
2143 protected: 2158 protected:
2144 // PagedSpaces that should be included in snapshots have different, i.e., 2159 // PagedSpaces that should be included in snapshots have different, i.e.,
2145 // smaller, initial pages. 2160 // smaller, initial pages.
2146 virtual bool snapshotable() { return true; } 2161 virtual bool snapshotable() { return true; }
2147 2162
2148 bool HasPages() { return anchor_.next_page() != &anchor_; } 2163 bool HasPages() { return anchor_.next_page() != &anchor_; }
2149 2164
2150 // Cleans up the space, frees all pages in this space except those belonging 2165 // Cleans up the space, frees all pages in this space except those belonging
2151 // to the initial chunk, uncommits addresses in the initial chunk. 2166 // to the initial chunk, uncommits addresses in the initial chunk.
2152 void TearDown(); 2167 void TearDown();
(...skipping 832 matching lines...) Expand 10 before | Expand all | Expand 10 after
2985 count = 0; 3000 count = 0;
2986 } 3001 }
2987 // Must be small, since an iteration is used for lookup. 3002 // Must be small, since an iteration is used for lookup.
2988 static const int kMaxComments = 64; 3003 static const int kMaxComments = 64;
2989 }; 3004 };
2990 #endif 3005 #endif
2991 } // namespace internal 3006 } // namespace internal
2992 } // namespace v8 3007 } // namespace v8
2993 3008
2994 #endif // V8_HEAP_SPACES_H_ 3009 #endif // V8_HEAP_SPACES_H_
OLDNEW
« no previous file with comments | « src/heap/mark-compact.cc ('k') | src/heap/spaces.cc » ('j') | src/heap/spaces.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698