Mercurial > hg > graal-compiler
comparison src/share/vm/gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.hpp @ 6026:9f059abe8cf2
7131629: Generalize the CMS free list code
Summary: Make the FreeChunk, FreeList, TreeList, and BinaryTreeDictionary classes usable outside CMS.
Reviewed-by: brutisso, johnc, jwilhelm
Contributed-by: coleen.phillimore@oracle.com
author | jmasa |
---|---|
date | Thu, 29 Mar 2012 19:46:24 -0700 |
parents | b632e80fc9dc |
children | f69a5d43dc19 |
comparison
equal
deleted
inserted
replaced
6016:3c91f2c9fd21 | 6026:9f059abe8cf2 |
---|---|
23 */ | 23 */ |
24 | 24 |
25 #ifndef SHARE_VM_GC_IMPLEMENTATION_CONCURRENTMARKSWEEP_COMPACTIBLEFREELISTSPACE_HPP | 25 #ifndef SHARE_VM_GC_IMPLEMENTATION_CONCURRENTMARKSWEEP_COMPACTIBLEFREELISTSPACE_HPP |
26 #define SHARE_VM_GC_IMPLEMENTATION_CONCURRENTMARKSWEEP_COMPACTIBLEFREELISTSPACE_HPP | 26 #define SHARE_VM_GC_IMPLEMENTATION_CONCURRENTMARKSWEEP_COMPACTIBLEFREELISTSPACE_HPP |
27 | 27 |
28 #include "gc_implementation/concurrentMarkSweep/binaryTreeDictionary.hpp" | |
29 #include "gc_implementation/concurrentMarkSweep/freeList.hpp" | |
30 #include "gc_implementation/concurrentMarkSweep/promotionInfo.hpp" | 28 #include "gc_implementation/concurrentMarkSweep/promotionInfo.hpp" |
29 #include "memory/binaryTreeDictionary.hpp" | |
31 #include "memory/blockOffsetTable.inline.hpp" | 30 #include "memory/blockOffsetTable.inline.hpp" |
31 #include "memory/freeList.hpp" | |
32 #include "memory/space.hpp" | 32 #include "memory/space.hpp" |
33 | 33 |
34 // Classes in support of keeping track of promotions into a non-Contiguous | 34 // Classes in support of keeping track of promotions into a non-Contiguous |
35 // space, in this case a CompactibleFreeListSpace. | 35 // space, in this case a CompactibleFreeListSpace. |
36 | 36 |
127 void assert_locked(const Mutex* lock) const PRODUCT_RETURN; | 127 void assert_locked(const Mutex* lock) const PRODUCT_RETURN; |
128 | 128 |
129 // Linear allocation blocks | 129 // Linear allocation blocks |
130 LinearAllocBlock _smallLinearAllocBlock; | 130 LinearAllocBlock _smallLinearAllocBlock; |
131 | 131 |
132 FreeBlockDictionary::DictionaryChoice _dictionaryChoice; | 132 FreeBlockDictionary<FreeChunk>::DictionaryChoice _dictionaryChoice; |
133 FreeBlockDictionary* _dictionary; // ptr to dictionary for large size blocks | 133 FreeBlockDictionary<FreeChunk>* _dictionary; // ptr to dictionary for large size blocks |
134 | 134 |
135 FreeList _indexedFreeList[IndexSetSize]; | 135 FreeList<FreeChunk> _indexedFreeList[IndexSetSize]; |
136 // indexed array for small size blocks | 136 // indexed array for small size blocks |
137 // allocation stategy | 137 // allocation stategy |
138 bool _fitStrategy; // Use best fit strategy. | 138 bool _fitStrategy; // Use best fit strategy. |
139 bool _adaptive_freelists; // Use adaptive freelists | 139 bool _adaptive_freelists; // Use adaptive freelists |
140 | 140 |
167 // required to be smaller than "IndexSetSize".) If successful, | 167 // required to be smaller than "IndexSetSize".) If successful, |
168 // adds them to "fl", which is required to be an empty free list. | 168 // adds them to "fl", which is required to be an empty free list. |
169 // If the count of "fl" is negative, it's absolute value indicates a | 169 // If the count of "fl" is negative, it's absolute value indicates a |
170 // number of free chunks that had been previously "borrowed" from global | 170 // number of free chunks that had been previously "borrowed" from global |
171 // list of size "word_sz", and must now be decremented. | 171 // list of size "word_sz", and must now be decremented. |
172 void par_get_chunk_of_blocks(size_t word_sz, size_t n, FreeList* fl); | 172 void par_get_chunk_of_blocks(size_t word_sz, size_t n, FreeList<FreeChunk>* fl); |
173 | 173 |
174 // Allocation helper functions | 174 // Allocation helper functions |
175 // Allocate using a strategy that takes from the indexed free lists | 175 // Allocate using a strategy that takes from the indexed free lists |
176 // first. This allocation strategy assumes a companion sweeping | 176 // first. This allocation strategy assumes a companion sweeping |
177 // strategy that attempts to keep the needed number of chunks in each | 177 // strategy that attempts to keep the needed number of chunks in each |
213 // For free list "fl" of chunks of size > numWords, | 213 // For free list "fl" of chunks of size > numWords, |
214 // remove a chunk, split off a chunk of size numWords | 214 // remove a chunk, split off a chunk of size numWords |
215 // and return it. The split off remainder is returned to | 215 // and return it. The split off remainder is returned to |
216 // the free lists. The old name for getFromListGreater | 216 // the free lists. The old name for getFromListGreater |
217 // was lookInListGreater. | 217 // was lookInListGreater. |
218 FreeChunk* getFromListGreater(FreeList* fl, size_t numWords); | 218 FreeChunk* getFromListGreater(FreeList<FreeChunk>* fl, size_t numWords); |
219 // Get a chunk in the indexed free list or dictionary, | 219 // Get a chunk in the indexed free list or dictionary, |
220 // by considering a larger chunk and splitting it. | 220 // by considering a larger chunk and splitting it. |
221 FreeChunk* getChunkFromGreater(size_t numWords); | 221 FreeChunk* getChunkFromGreater(size_t numWords); |
222 // Verify that the given chunk is in the indexed free lists. | 222 // Verify that the given chunk is in the indexed free lists. |
223 bool verifyChunkInIndexedFreeLists(FreeChunk* fc) const; | 223 bool verifyChunkInIndexedFreeLists(FreeChunk* fc) const; |
284 | 284 |
285 public: | 285 public: |
286 // Constructor... | 286 // Constructor... |
287 CompactibleFreeListSpace(BlockOffsetSharedArray* bs, MemRegion mr, | 287 CompactibleFreeListSpace(BlockOffsetSharedArray* bs, MemRegion mr, |
288 bool use_adaptive_freelists, | 288 bool use_adaptive_freelists, |
289 FreeBlockDictionary::DictionaryChoice); | 289 FreeBlockDictionary<FreeChunk>::DictionaryChoice); |
290 // accessors | 290 // accessors |
291 bool bestFitFirst() { return _fitStrategy == FreeBlockBestFitFirst; } | 291 bool bestFitFirst() { return _fitStrategy == FreeBlockBestFitFirst; } |
292 FreeBlockDictionary* dictionary() const { return _dictionary; } | 292 FreeBlockDictionary<FreeChunk>* dictionary() const { return _dictionary; } |
293 HeapWord* nearLargestChunk() const { return _nearLargestChunk; } | 293 HeapWord* nearLargestChunk() const { return _nearLargestChunk; } |
294 void set_nearLargestChunk(HeapWord* v) { _nearLargestChunk = v; } | 294 void set_nearLargestChunk(HeapWord* v) { _nearLargestChunk = v; } |
295 | 295 |
296 // Set CMS global values | 296 // Set CMS global values |
297 static void set_cms_values(); | 297 static void set_cms_values(); |
620 class CFLS_LAB : public CHeapObj { | 620 class CFLS_LAB : public CHeapObj { |
621 // The space that this buffer allocates into. | 621 // The space that this buffer allocates into. |
622 CompactibleFreeListSpace* _cfls; | 622 CompactibleFreeListSpace* _cfls; |
623 | 623 |
624 // Our local free lists. | 624 // Our local free lists. |
625 FreeList _indexedFreeList[CompactibleFreeListSpace::IndexSetSize]; | 625 FreeList<FreeChunk> _indexedFreeList[CompactibleFreeListSpace::IndexSetSize]; |
626 | 626 |
627 // Initialized from a command-line arg. | 627 // Initialized from a command-line arg. |
628 | 628 |
629 // Allocation statistics in support of dynamic adjustment of | 629 // Allocation statistics in support of dynamic adjustment of |
630 // #blocks to claim per get_from_global_pool() call below. | 630 // #blocks to claim per get_from_global_pool() call below. |
633 static size_t _global_num_blocks [CompactibleFreeListSpace::IndexSetSize]; | 633 static size_t _global_num_blocks [CompactibleFreeListSpace::IndexSetSize]; |
634 static uint _global_num_workers[CompactibleFreeListSpace::IndexSetSize]; | 634 static uint _global_num_workers[CompactibleFreeListSpace::IndexSetSize]; |
635 size_t _num_blocks [CompactibleFreeListSpace::IndexSetSize]; | 635 size_t _num_blocks [CompactibleFreeListSpace::IndexSetSize]; |
636 | 636 |
637 // Internal work method | 637 // Internal work method |
638 void get_from_global_pool(size_t word_sz, FreeList* fl); | 638 void get_from_global_pool(size_t word_sz, FreeList<FreeChunk>* fl); |
639 | 639 |
640 public: | 640 public: |
641 CFLS_LAB(CompactibleFreeListSpace* cfls); | 641 CFLS_LAB(CompactibleFreeListSpace* cfls); |
642 | 642 |
643 // Allocate and return a block of the given size, or else return NULL. | 643 // Allocate and return a block of the given size, or else return NULL. |