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

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
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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 77
78 // Some assertion macros used in the debugging mode. 78 // Some assertion macros used in the debugging mode.
79 79
80 #define DCHECK_PAGE_ALIGNED(address) \ 80 #define DCHECK_PAGE_ALIGNED(address) \
81 DCHECK((OffsetFrom(address) & Page::kPageAlignmentMask) == 0) 81 DCHECK((OffsetFrom(address) & Page::kPageAlignmentMask) == 0)
82 82
83 #define DCHECK_OBJECT_ALIGNED(address) \ 83 #define DCHECK_OBJECT_ALIGNED(address) \
84 DCHECK((OffsetFrom(address) & kObjectAlignmentMask) == 0) 84 DCHECK((OffsetFrom(address) & kObjectAlignmentMask) == 0)
85 85
86 #define DCHECK_OBJECT_SIZE(size) \ 86 #define DCHECK_OBJECT_SIZE(size) \
87 DCHECK((0 < size) && (size <= Page::kMaxRegularHeapObjectSize)) 87 DCHECK((0 < size) && (size <= Page::kAllocatableMemory))
88 88
89 #define DCHECK_PAGE_OFFSET(offset) \ 89 #define DCHECK_PAGE_OFFSET(offset) \
90 DCHECK((Page::kObjectStartOffset <= offset) && (offset <= Page::kPageSize)) 90 DCHECK((Page::kObjectStartOffset <= offset) && (offset <= Page::kPageSize))
91 91
92 #define DCHECK_MAP_PAGE_INDEX(index) \ 92 #define DCHECK_MAP_PAGE_INDEX(index) \
93 DCHECK((0 <= index) && (index <= MapSpace::kMaxMapPageIndex)) 93 DCHECK((0 <= index) && (index <= MapSpace::kMaxMapPageIndex))
94 94
95 class AllocationInfo; 95 class AllocationInfo;
96 class CompactionSpace; 96 class CompactionSpace;
97 class FreeList; 97 class FreeList;
(...skipping 706 matching lines...) Expand 10 before | Expand all | Expand 10 after
804 Address OffsetToAddress(int offset) { 804 Address OffsetToAddress(int offset) {
805 DCHECK_PAGE_OFFSET(offset); 805 DCHECK_PAGE_OFFSET(offset);
806 return address() + offset; 806 return address() + offset;
807 } 807 }
808 808
809 // --------------------------------------------------------------------- 809 // ---------------------------------------------------------------------
810 810
811 // Page size in bytes. This must be a multiple of the OS page size. 811 // Page size in bytes. This must be a multiple of the OS page size.
812 static const int kPageSize = 1 << kPageSizeBits; 812 static const int kPageSize = 1 << kPageSizeBits;
813 813
814 // Maximum object size that fits in a page. Objects larger than that size 814 // Maximum object size that gets allocated into regular pages. Objects larger
815 // are allocated in large object space and are never moved in memory. This 815 // than that size are allocated in large object space and are never moved in
816 // also applies to new space allocation, since objects are never migrated 816 // memory. This also applies to new space allocation, since objects are never
817 // from new space to large object space. Takes double alignment into account. 817 // migrated from new space to large object space. Takes double alignment into
818 // account.
818 static const int kMaxRegularHeapObjectSize = kPageSize - kObjectStartOffset; 819 static const int kMaxRegularHeapObjectSize = kPageSize - kObjectStartOffset;
819 820
821 static const int kAllocatableMemory = kPageSize - kObjectStartOffset;
822
820 // Page size mask. 823 // Page size mask.
821 static const intptr_t kPageAlignmentMask = (1 << kPageSizeBits) - 1; 824 static const intptr_t kPageAlignmentMask = (1 << kPageSizeBits) - 1;
822 825
823 inline void ClearGCFields(); 826 inline void ClearGCFields();
824 827
825 static inline Page* Initialize(Heap* heap, MemoryChunk* chunk, 828 static inline Page* Initialize(Heap* heap, MemoryChunk* chunk,
826 Executability executable, PagedSpace* owner); 829 Executability executable, PagedSpace* owner);
827 830
828 void InitializeAsAnchor(PagedSpace* owner); 831 void InitializeAsAnchor(PagedSpace* owner);
829 832
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
1140 1143
1141 // Returns the maximum available executable bytes of heaps. 1144 // Returns the maximum available executable bytes of heaps.
1142 intptr_t AvailableExecutable() { 1145 intptr_t AvailableExecutable() {
1143 intptr_t executable_size = SizeExecutable(); 1146 intptr_t executable_size = SizeExecutable();
1144 if (capacity_executable_ < executable_size) return 0; 1147 if (capacity_executable_ < executable_size) return 0;
1145 return capacity_executable_ - executable_size; 1148 return capacity_executable_ - executable_size;
1146 } 1149 }
1147 1150
1148 // Returns maximum available bytes that the old space can have. 1151 // Returns maximum available bytes that the old space can have.
1149 intptr_t MaxAvailable() { 1152 intptr_t MaxAvailable() {
1150 return (Available() / Page::kPageSize) * Page::kMaxRegularHeapObjectSize; 1153 return (Available() / Page::kPageSize) * Page::kAllocatableMemory;
1151 } 1154 }
1152 1155
1153 // Returns an indication of whether a pointer is in a space that has 1156 // Returns an indication of whether a pointer is in a space that has
1154 // been allocated by this MemoryAllocator. 1157 // been allocated by this MemoryAllocator.
1155 V8_INLINE bool IsOutsideAllocatedSpace(const void* address) { 1158 V8_INLINE bool IsOutsideAllocatedSpace(const void* address) {
1156 return address < lowest_ever_allocated_.Value() || 1159 return address < lowest_ever_allocated_.Value() ||
1157 address >= highest_ever_allocated_.Value(); 1160 address >= highest_ever_allocated_.Value();
1158 } 1161 }
1159 1162
1160 #ifdef DEBUG 1163 #ifdef DEBUG
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1216 1219
1217 static int CodePageAreaEndOffset(); 1220 static int CodePageAreaEndOffset();
1218 1221
1219 static int CodePageAreaSize() { 1222 static int CodePageAreaSize() {
1220 return CodePageAreaEndOffset() - CodePageAreaStartOffset(); 1223 return CodePageAreaEndOffset() - CodePageAreaStartOffset();
1221 } 1224 }
1222 1225
1223 static int PageAreaSize(AllocationSpace space) { 1226 static int PageAreaSize(AllocationSpace space) {
1224 DCHECK_NE(LO_SPACE, space); 1227 DCHECK_NE(LO_SPACE, space);
1225 return (space == CODE_SPACE) ? CodePageAreaSize() 1228 return (space == CODE_SPACE) ? CodePageAreaSize()
1226 : Page::kMaxRegularHeapObjectSize; 1229 : Page::kAllocatableMemory;
1227 } 1230 }
1228 1231
1229 MUST_USE_RESULT bool CommitExecutableMemory(base::VirtualMemory* vm, 1232 MUST_USE_RESULT bool CommitExecutableMemory(base::VirtualMemory* vm,
1230 Address start, size_t commit_size, 1233 Address start, size_t commit_size,
1231 size_t reserved_size); 1234 size_t reserved_size);
1232 1235
1233 private: 1236 private:
1234 Isolate* isolate_; 1237 Isolate* isolate_;
1235 1238
1236 // Maximum space size in bytes. 1239 // Maximum space size in bytes.
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
1677 FreeListCategory* small_list() { return &small_list_; } 1680 FreeListCategory* small_list() { return &small_list_; }
1678 FreeListCategory* medium_list() { return &medium_list_; } 1681 FreeListCategory* medium_list() { return &medium_list_; }
1679 FreeListCategory* large_list() { return &large_list_; } 1682 FreeListCategory* large_list() { return &large_list_; }
1680 FreeListCategory* huge_list() { return &huge_list_; } 1683 FreeListCategory* huge_list() { return &huge_list_; }
1681 1684
1682 PagedSpace* owner() { return owner_; } 1685 PagedSpace* owner() { return owner_; }
1683 1686
1684 private: 1687 private:
1685 // The size range of blocks, in bytes. 1688 // The size range of blocks, in bytes.
1686 static const int kMinBlockSize = 3 * kPointerSize; 1689 static const int kMinBlockSize = 3 * kPointerSize;
1687 static const int kMaxBlockSize = Page::kMaxRegularHeapObjectSize; 1690 static const int kMaxBlockSize = Page::kAllocatableMemory;
1688 1691
1689 static const int kSmallListMin = 0x1f * kPointerSize; 1692 static const int kSmallListMin = 0x1f * kPointerSize;
1690 static const int kSmallListMax = 0xff * kPointerSize; 1693 static const int kSmallListMax = 0xff * kPointerSize;
1691 static const int kMediumListMax = 0x7ff * kPointerSize; 1694 static const int kMediumListMax = 0x7ff * kPointerSize;
1692 static const int kLargeListMax = 0x3fff * kPointerSize; 1695 static const int kLargeListMax = 0x3fff * kPointerSize;
1693 static const int kSmallAllocationMax = kSmallListMin; 1696 static const int kSmallAllocationMax = kSmallListMin;
1694 static const int kMediumAllocationMax = kSmallListMax; 1697 static const int kMediumAllocationMax = kSmallListMax;
1695 static const int kLargeAllocationMax = kMediumListMax; 1698 static const int kLargeAllocationMax = kMediumListMax;
1696 1699
1697 FreeSpace* FindNodeFor(int size_in_bytes, int* node_size); 1700 FreeSpace* FindNodeFor(int size_in_bytes, int* node_size);
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
2096 2099
2097 class NewSpacePage : public MemoryChunk { 2100 class NewSpacePage : public MemoryChunk {
2098 public: 2101 public:
2099 // GC related flags copied from from-space to to-space when 2102 // GC related flags copied from from-space to to-space when
2100 // flipping semispaces. 2103 // flipping semispaces.
2101 static const intptr_t kCopyOnFlipFlagsMask = 2104 static const intptr_t kCopyOnFlipFlagsMask =
2102 (1 << MemoryChunk::POINTERS_TO_HERE_ARE_INTERESTING) | 2105 (1 << MemoryChunk::POINTERS_TO_HERE_ARE_INTERESTING) |
2103 (1 << MemoryChunk::POINTERS_FROM_HERE_ARE_INTERESTING) | 2106 (1 << MemoryChunk::POINTERS_FROM_HERE_ARE_INTERESTING) |
2104 (1 << MemoryChunk::SCAN_ON_SCAVENGE); 2107 (1 << MemoryChunk::SCAN_ON_SCAVENGE);
2105 2108
2106 static const int kAreaSize = Page::kMaxRegularHeapObjectSize; 2109 static const int kAreaSize = Page::kAllocatableMemory;
2107 2110
2108 inline NewSpacePage* next_page() { 2111 inline NewSpacePage* next_page() {
2109 return static_cast<NewSpacePage*>(next_chunk()); 2112 return static_cast<NewSpacePage*>(next_chunk());
2110 } 2113 }
2111 2114
2112 inline void set_next_page(NewSpacePage* page) { set_next_chunk(page); } 2115 inline void set_next_page(NewSpacePage* page) { set_next_chunk(page); }
2113 2116
2114 inline NewSpacePage* prev_page() { 2117 inline NewSpacePage* prev_page() {
2115 return static_cast<NewSpacePage*>(prev_chunk()); 2118 return static_cast<NewSpacePage*>(prev_chunk());
2116 } 2119 }
(...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after
2815 return RoundDown(size, Map::kSize); 2818 return RoundDown(size, Map::kSize);
2816 } else { 2819 } else {
2817 return (size / Map::kSize) * Map::kSize; 2820 return (size / Map::kSize) * Map::kSize;
2818 } 2821 }
2819 } 2822 }
2820 2823
2821 protected: 2824 protected:
2822 virtual void VerifyObject(HeapObject* obj); 2825 virtual void VerifyObject(HeapObject* obj);
2823 2826
2824 private: 2827 private:
2825 static const int kMapsPerPage = Page::kMaxRegularHeapObjectSize / Map::kSize; 2828 static const int kMapsPerPage = Page::kAllocatableMemory / Map::kSize;
2826 2829
2827 // Do map space compaction if there is a page gap. 2830 // Do map space compaction if there is a page gap.
2828 int CompactionThreshold() { 2831 int CompactionThreshold() {
2829 return kMapsPerPage * (max_map_space_pages_ - 1); 2832 return kMapsPerPage * (max_map_space_pages_ - 1);
2830 } 2833 }
2831 2834
2832 const int max_map_space_pages_; 2835 const int max_map_space_pages_;
2833 }; 2836 };
2834 2837
2835 2838
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
2970 count = 0; 2973 count = 0;
2971 } 2974 }
2972 // Must be small, since an iteration is used for lookup. 2975 // Must be small, since an iteration is used for lookup.
2973 static const int kMaxComments = 64; 2976 static const int kMaxComments = 64;
2974 }; 2977 };
2975 #endif 2978 #endif
2976 } 2979 }
2977 } // namespace v8::internal 2980 } // namespace v8::internal
2978 2981
2979 #endif // V8_HEAP_SPACES_H_ 2982 #endif // V8_HEAP_SPACES_H_
OLDNEW
« no previous file with comments | « src/heap/heap.cc ('k') | src/heap/spaces-inl.h » ('j') | test/cctest/test-api.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698