66 size_t min_chunk_size_in_bytes = align_size_up(sizeof(FreeChunk), MinObjAlignmentInBytes);
67 MinChunkSize = min_chunk_size_in_bytes / BytesPerWord;
68
69 assert(IndexSetStart == 0 && IndexSetStride == 0, "already set");
70 IndexSetStart = MinChunkSize;
71 IndexSetStride = MinObjAlignment;
72 }
73
74 // Constructor
75 CompactibleFreeListSpace::CompactibleFreeListSpace(BlockOffsetSharedArray* bs,
76 MemRegion mr, bool use_adaptive_freelists,
77 FreeBlockDictionary<FreeChunk>::DictionaryChoice dictionaryChoice) :
78 _dictionaryChoice(dictionaryChoice),
79 _adaptive_freelists(use_adaptive_freelists),
80 _bt(bs, mr),
81 // free list locks are in the range of values taken by _lockRank
82 // This range currently is [_leaf+2, _leaf+3]
83 // Note: this requires that CFLspace c'tors
84 // are called serially in the order in which the locks are
85 // are acquired in the program text. This is true today.
86 _freelistLock(_lockRank--, "CompactibleFreeListSpace._lock", true),
87 _parDictionaryAllocLock(Mutex::leaf - 1, // == rank(ExpandHeap_lock) - 1
88 "CompactibleFreeListSpace._dict_par_lock", true),
89 _rescan_task_size(CardTableModRefBS::card_size_in_words * BitsPerWord *
90 CMSRescanMultiple),
91 _marking_task_size(CardTableModRefBS::card_size_in_words * BitsPerWord *
92 CMSConcMarkMultiple),
93 _collector(NULL)
94 {
95 assert(sizeof(FreeChunk) / BytesPerWord <= MinChunkSize,
96 "FreeChunk is larger than expected");
97 _bt.set_space(this);
98 initialize(mr, SpaceDecorator::Clear, SpaceDecorator::Mangle);
99 // We have all of "mr", all of which we place in the dictionary
100 // as one big chunk. We'll need to decide here which of several
101 // possible alternative dictionary implementations to use. For
102 // now the choice is easy, since we have only one working
103 // implementation, namely, the simple binary tree (splaying
104 // temporarily disabled).
105 switch (dictionaryChoice) {
106 case FreeBlockDictionary<FreeChunk>::dictionaryBinaryTree:
107 _dictionary = new AFLBinaryTreeDictionary(mr);
108 break;
134 // Note that _unallocated_block is not updated here.
135 // Allocations from the linear allocation block should
136 // update it.
137 } else {
138 _smallLinearAllocBlock.set(0, 0, 1024*SmallForLinearAlloc,
139 SmallForLinearAlloc);
140 }
141 // CMSIndexedFreeListReplenish should be at least 1
142 CMSIndexedFreeListReplenish = MAX2((uintx)1, CMSIndexedFreeListReplenish);
143 _promoInfo.setSpace(this);
144 if (UseCMSBestFit) {
145 _fitStrategy = FreeBlockBestFitFirst;
146 } else {
147 _fitStrategy = FreeBlockStrategyNone;
148 }
149 check_free_list_consistency();
150
151 // Initialize locks for parallel case.
152 for (size_t i = IndexSetStart; i < IndexSetSize; i += IndexSetStride) {
153 _indexedFreeListParLocks[i] = new Mutex(Mutex::leaf - 1, // == ExpandHeap_lock - 1
154 "a freelist par lock",
155 true);
156 DEBUG_ONLY(
157 _indexedFreeList[i].set_protecting_lock(_indexedFreeListParLocks[i]);
158 )
159 }
160 _dictionary->set_par_lock(&_parDictionaryAllocLock);
161 }
162
163 // Like CompactibleSpace forward() but always calls cross_threshold() to
164 // update the block offset table. Removed initialize_threshold call because
165 // CFLS does not use a block offset array for contiguous spaces.
166 HeapWord* CompactibleFreeListSpace::forward(oop q, size_t size,
167 CompactPoint* cp, HeapWord* compact_top) {
168 // q is alive
169 // First check if we should switch compaction space
170 assert(this == cp->space, "'this' should be current compaction space.");
171 size_t compaction_max_size = pointer_delta(end(), compact_top);
172 assert(adjustObjectSize(size) == cp->space->adjust_object_size_v(size),
173 "virtual adjustObjectSize_v() method is not correct");
174 size_t adjusted_size = adjustObjectSize(size);
175 assert(compaction_max_size >= MinChunkSize || compaction_max_size == 0,
|
66 size_t min_chunk_size_in_bytes = align_size_up(sizeof(FreeChunk), MinObjAlignmentInBytes);
67 MinChunkSize = min_chunk_size_in_bytes / BytesPerWord;
68
69 assert(IndexSetStart == 0 && IndexSetStride == 0, "already set");
70 IndexSetStart = MinChunkSize;
71 IndexSetStride = MinObjAlignment;
72 }
73
74 // Constructor
75 CompactibleFreeListSpace::CompactibleFreeListSpace(BlockOffsetSharedArray* bs,
76 MemRegion mr, bool use_adaptive_freelists,
77 FreeBlockDictionary<FreeChunk>::DictionaryChoice dictionaryChoice) :
78 _dictionaryChoice(dictionaryChoice),
79 _adaptive_freelists(use_adaptive_freelists),
80 _bt(bs, mr),
81 // free list locks are in the range of values taken by _lockRank
82 // This range currently is [_leaf+2, _leaf+3]
83 // Note: this requires that CFLspace c'tors
84 // are called serially in the order in which the locks are
85 // are acquired in the program text. This is true today.
86 _freelistLock(_lockRank--, "CompactibleFreeListSpace._lock", true,
87 Monitor::_safepoint_check_sometimes),
88 _parDictionaryAllocLock(Mutex::leaf - 1, // == rank(ExpandHeap_lock) - 1
89 "CompactibleFreeListSpace._dict_par_lock", true,
90 Monitor::_safepoint_check_never),
91 _rescan_task_size(CardTableModRefBS::card_size_in_words * BitsPerWord *
92 CMSRescanMultiple),
93 _marking_task_size(CardTableModRefBS::card_size_in_words * BitsPerWord *
94 CMSConcMarkMultiple),
95 _collector(NULL)
96 {
97 assert(sizeof(FreeChunk) / BytesPerWord <= MinChunkSize,
98 "FreeChunk is larger than expected");
99 _bt.set_space(this);
100 initialize(mr, SpaceDecorator::Clear, SpaceDecorator::Mangle);
101 // We have all of "mr", all of which we place in the dictionary
102 // as one big chunk. We'll need to decide here which of several
103 // possible alternative dictionary implementations to use. For
104 // now the choice is easy, since we have only one working
105 // implementation, namely, the simple binary tree (splaying
106 // temporarily disabled).
107 switch (dictionaryChoice) {
108 case FreeBlockDictionary<FreeChunk>::dictionaryBinaryTree:
109 _dictionary = new AFLBinaryTreeDictionary(mr);
110 break;
136 // Note that _unallocated_block is not updated here.
137 // Allocations from the linear allocation block should
138 // update it.
139 } else {
140 _smallLinearAllocBlock.set(0, 0, 1024*SmallForLinearAlloc,
141 SmallForLinearAlloc);
142 }
143 // CMSIndexedFreeListReplenish should be at least 1
144 CMSIndexedFreeListReplenish = MAX2((uintx)1, CMSIndexedFreeListReplenish);
145 _promoInfo.setSpace(this);
146 if (UseCMSBestFit) {
147 _fitStrategy = FreeBlockBestFitFirst;
148 } else {
149 _fitStrategy = FreeBlockStrategyNone;
150 }
151 check_free_list_consistency();
152
153 // Initialize locks for parallel case.
154 for (size_t i = IndexSetStart; i < IndexSetSize; i += IndexSetStride) {
155 _indexedFreeListParLocks[i] = new Mutex(Mutex::leaf - 1, // == ExpandHeap_lock - 1
156 "a freelist par lock", true, Mutex::_safepoint_check_sometimes);
157 DEBUG_ONLY(
158 _indexedFreeList[i].set_protecting_lock(_indexedFreeListParLocks[i]);
159 )
160 }
161 _dictionary->set_par_lock(&_parDictionaryAllocLock);
162 }
163
164 // Like CompactibleSpace forward() but always calls cross_threshold() to
165 // update the block offset table. Removed initialize_threshold call because
166 // CFLS does not use a block offset array for contiguous spaces.
167 HeapWord* CompactibleFreeListSpace::forward(oop q, size_t size,
168 CompactPoint* cp, HeapWord* compact_top) {
169 // q is alive
170 // First check if we should switch compaction space
171 assert(this == cp->space, "'this' should be current compaction space.");
172 size_t compaction_max_size = pointer_delta(end(), compact_top);
173 assert(adjustObjectSize(size) == cp->space->adjust_object_size_v(size),
174 "virtual adjustObjectSize_v() method is not correct");
175 size_t adjusted_size = adjustObjectSize(size);
176 assert(compaction_max_size >= MinChunkSize || compaction_max_size == 0,
|