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

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

Issue 1361853005: [heap] Prepare code for smaller large object allocation limit than max allocatable memory. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 2 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
« no previous file with comments | « src/heap/heap.cc ('k') | src/heap/spaces-inl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "src/allocation.h" 8 #include "src/allocation.h"
9 #include "src/atomic-utils.h" 9 #include "src/atomic-utils.h"
10 #include "src/base/atomicops.h" 10 #include "src/base/atomicops.h"
(...skipping 796 matching lines...) Expand 10 before | Expand all | Expand 10 after
807 Address OffsetToAddress(int offset) { 807 Address OffsetToAddress(int offset) {
808 DCHECK_PAGE_OFFSET(offset); 808 DCHECK_PAGE_OFFSET(offset);
809 return address() + offset; 809 return address() + offset;
810 } 810 }
811 811
812 // --------------------------------------------------------------------- 812 // ---------------------------------------------------------------------
813 813
814 // Page size in bytes. This must be a multiple of the OS page size. 814 // Page size in bytes. This must be a multiple of the OS page size.
815 static const int kPageSize = 1 << kPageSizeBits; 815 static const int kPageSize = 1 << kPageSizeBits;
816 816
817 // Maximum object size that fits in a page. Objects larger than that size 817 // Maximum object size that gets allocated into regular pages. Objects larger
818 // are allocated in large object space and are never moved in memory. This 818 // than that size are allocated in large object space and are never moved in
819 // also applies to new space allocation, since objects are never migrated 819 // memory. This also applies to new space allocation, since objects are never
820 // from new space to large object space. Takes double alignment into account. 820 // migrated from new space to large object space. Takes double alignment into
821 // account.
821 static const int kMaxRegularHeapObjectSize = kPageSize - kObjectStartOffset; 822 static const int kMaxRegularHeapObjectSize = kPageSize - kObjectStartOffset;
822 823
824 static const int kAllocatableMemory = kPageSize - kObjectStartOffset;
825
823 // Page size mask. 826 // Page size mask.
824 static const intptr_t kPageAlignmentMask = (1 << kPageSizeBits) - 1; 827 static const intptr_t kPageAlignmentMask = (1 << kPageSizeBits) - 1;
825 828
826 inline void ClearGCFields(); 829 inline void ClearGCFields();
827 830
828 static inline Page* Initialize(Heap* heap, MemoryChunk* chunk, 831 static inline Page* Initialize(Heap* heap, MemoryChunk* chunk,
829 Executability executable, PagedSpace* owner); 832 Executability executable, PagedSpace* owner);
830 833
831 void InitializeAsAnchor(PagedSpace* owner); 834 void InitializeAsAnchor(PagedSpace* owner);
832 835
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
1162 1165
1163 // Returns the maximum available executable bytes of heaps. 1166 // Returns the maximum available executable bytes of heaps.
1164 intptr_t AvailableExecutable() { 1167 intptr_t AvailableExecutable() {
1165 intptr_t executable_size = SizeExecutable(); 1168 intptr_t executable_size = SizeExecutable();
1166 if (capacity_executable_ < executable_size) return 0; 1169 if (capacity_executable_ < executable_size) return 0;
1167 return capacity_executable_ - executable_size; 1170 return capacity_executable_ - executable_size;
1168 } 1171 }
1169 1172
1170 // Returns maximum available bytes that the old space can have. 1173 // Returns maximum available bytes that the old space can have.
1171 intptr_t MaxAvailable() { 1174 intptr_t MaxAvailable() {
1172 return (Available() / Page::kPageSize) * Page::kMaxRegularHeapObjectSize; 1175 return (Available() / Page::kPageSize) * Page::kAllocatableMemory;
1173 } 1176 }
1174 1177
1175 // Returns an indication of whether a pointer is in a space that has 1178 // Returns an indication of whether a pointer is in a space that has
1176 // been allocated by this MemoryAllocator. 1179 // been allocated by this MemoryAllocator.
1177 V8_INLINE bool IsOutsideAllocatedSpace(const void* address) { 1180 V8_INLINE bool IsOutsideAllocatedSpace(const void* address) {
1178 return address < lowest_ever_allocated_.Value() || 1181 return address < lowest_ever_allocated_.Value() ||
1179 address >= highest_ever_allocated_.Value(); 1182 address >= highest_ever_allocated_.Value();
1180 } 1183 }
1181 1184
1182 #ifdef DEBUG 1185 #ifdef DEBUG
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1238 1241
1239 static int CodePageAreaEndOffset(); 1242 static int CodePageAreaEndOffset();
1240 1243
1241 static int CodePageAreaSize() { 1244 static int CodePageAreaSize() {
1242 return CodePageAreaEndOffset() - CodePageAreaStartOffset(); 1245 return CodePageAreaEndOffset() - CodePageAreaStartOffset();
1243 } 1246 }
1244 1247
1245 static int PageAreaSize(AllocationSpace space) { 1248 static int PageAreaSize(AllocationSpace space) {
1246 DCHECK_NE(LO_SPACE, space); 1249 DCHECK_NE(LO_SPACE, space);
1247 return (space == CODE_SPACE) ? CodePageAreaSize() 1250 return (space == CODE_SPACE) ? CodePageAreaSize()
1248 : Page::kMaxRegularHeapObjectSize; 1251 : Page::kAllocatableMemory;
1249 } 1252 }
1250 1253
1251 MUST_USE_RESULT bool CommitExecutableMemory(base::VirtualMemory* vm, 1254 MUST_USE_RESULT bool CommitExecutableMemory(base::VirtualMemory* vm,
1252 Address start, size_t commit_size, 1255 Address start, size_t commit_size,
1253 size_t reserved_size); 1256 size_t reserved_size);
1254 1257
1255 private: 1258 private:
1256 Isolate* isolate_; 1259 Isolate* isolate_;
1257 1260
1258 // Maximum space size in bytes. 1261 // Maximum space size in bytes.
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
1693 FreeListCategory* large_list() { return &large_list_; } 1696 FreeListCategory* large_list() { return &large_list_; }
1694 FreeListCategory* huge_list() { return &huge_list_; } 1697 FreeListCategory* huge_list() { return &huge_list_; }
1695 1698
1696 PagedSpace* owner() { return owner_; } 1699 PagedSpace* owner() { return owner_; }
1697 intptr_t wasted_bytes() { return wasted_bytes_; } 1700 intptr_t wasted_bytes() { return wasted_bytes_; }
1698 base::Mutex* mutex() { return &mutex_; } 1701 base::Mutex* mutex() { return &mutex_; }
1699 1702
1700 private: 1703 private:
1701 // The size range of blocks, in bytes. 1704 // The size range of blocks, in bytes.
1702 static const int kMinBlockSize = 3 * kPointerSize; 1705 static const int kMinBlockSize = 3 * kPointerSize;
1703 static const int kMaxBlockSize = Page::kMaxRegularHeapObjectSize; 1706 static const int kMaxBlockSize = Page::kAllocatableMemory;
1704 1707
1705 static const int kSmallListMin = 0x1f * kPointerSize; 1708 static const int kSmallListMin = 0x1f * kPointerSize;
1706 static const int kSmallListMax = 0xff * kPointerSize; 1709 static const int kSmallListMax = 0xff * kPointerSize;
1707 static const int kMediumListMax = 0x7ff * kPointerSize; 1710 static const int kMediumListMax = 0x7ff * kPointerSize;
1708 static const int kLargeListMax = 0x3fff * kPointerSize; 1711 static const int kLargeListMax = 0x3fff * kPointerSize;
1709 static const int kSmallAllocationMax = kSmallListMin; 1712 static const int kSmallAllocationMax = kSmallListMin;
1710 static const int kMediumAllocationMax = kSmallListMax; 1713 static const int kMediumAllocationMax = kSmallListMax;
1711 static const int kLargeAllocationMax = kMediumListMax; 1714 static const int kLargeAllocationMax = kMediumListMax;
1712 1715
1713 FreeSpace* FindNodeFor(int size_in_bytes, int* node_size); 1716 FreeSpace* FindNodeFor(int size_in_bytes, int* node_size);
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
2113 2116
2114 class NewSpacePage : public MemoryChunk { 2117 class NewSpacePage : public MemoryChunk {
2115 public: 2118 public:
2116 // GC related flags copied from from-space to to-space when 2119 // GC related flags copied from from-space to to-space when
2117 // flipping semispaces. 2120 // flipping semispaces.
2118 static const intptr_t kCopyOnFlipFlagsMask = 2121 static const intptr_t kCopyOnFlipFlagsMask =
2119 (1 << MemoryChunk::POINTERS_TO_HERE_ARE_INTERESTING) | 2122 (1 << MemoryChunk::POINTERS_TO_HERE_ARE_INTERESTING) |
2120 (1 << MemoryChunk::POINTERS_FROM_HERE_ARE_INTERESTING) | 2123 (1 << MemoryChunk::POINTERS_FROM_HERE_ARE_INTERESTING) |
2121 (1 << MemoryChunk::SCAN_ON_SCAVENGE); 2124 (1 << MemoryChunk::SCAN_ON_SCAVENGE);
2122 2125
2123 static const int kAreaSize = Page::kMaxRegularHeapObjectSize; 2126 static const int kAreaSize = Page::kAllocatableMemory;
2124 2127
2125 inline NewSpacePage* next_page() { 2128 inline NewSpacePage* next_page() {
2126 return static_cast<NewSpacePage*>(next_chunk()); 2129 return static_cast<NewSpacePage*>(next_chunk());
2127 } 2130 }
2128 2131
2129 inline void set_next_page(NewSpacePage* page) { set_next_chunk(page); } 2132 inline void set_next_page(NewSpacePage* page) { set_next_chunk(page); }
2130 2133
2131 inline NewSpacePage* prev_page() { 2134 inline NewSpacePage* prev_page() {
2132 return static_cast<NewSpacePage*>(prev_chunk()); 2135 return static_cast<NewSpacePage*>(prev_chunk());
2133 } 2136 }
(...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after
2832 return RoundDown(size, Map::kSize); 2835 return RoundDown(size, Map::kSize);
2833 } else { 2836 } else {
2834 return (size / Map::kSize) * Map::kSize; 2837 return (size / Map::kSize) * Map::kSize;
2835 } 2838 }
2836 } 2839 }
2837 2840
2838 protected: 2841 protected:
2839 virtual void VerifyObject(HeapObject* obj); 2842 virtual void VerifyObject(HeapObject* obj);
2840 2843
2841 private: 2844 private:
2842 static const int kMapsPerPage = Page::kMaxRegularHeapObjectSize / Map::kSize; 2845 static const int kMapsPerPage = Page::kAllocatableMemory / Map::kSize;
2843 2846
2844 // Do map space compaction if there is a page gap. 2847 // Do map space compaction if there is a page gap.
2845 int CompactionThreshold() { 2848 int CompactionThreshold() {
2846 return kMapsPerPage * (max_map_space_pages_ - 1); 2849 return kMapsPerPage * (max_map_space_pages_ - 1);
2847 } 2850 }
2848 2851
2849 const int max_map_space_pages_; 2852 const int max_map_space_pages_;
2850 }; 2853 };
2851 2854
2852 2855
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
2987 count = 0; 2990 count = 0;
2988 } 2991 }
2989 // Must be small, since an iteration is used for lookup. 2992 // Must be small, since an iteration is used for lookup.
2990 static const int kMaxComments = 64; 2993 static const int kMaxComments = 64;
2991 }; 2994 };
2992 #endif 2995 #endif
2993 } // namespace internal 2996 } // namespace internal
2994 } // namespace v8 2997 } // namespace v8
2995 2998
2996 #endif // V8_HEAP_SPACES_H_ 2999 #endif // V8_HEAP_SPACES_H_
OLDNEW
« no previous file with comments | « src/heap/heap.cc ('k') | src/heap/spaces-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698