Mercurial > hg > truffle
comparison src/share/vm/gc_implementation/concurrentMarkSweep/freeBlockDictionary.hpp @ 187:790e66e5fbac
6687581: Make CMS work with compressed oops
Summary: Make FreeChunk read markword instead of LSB in _klass pointer to indicate that it's a FreeChunk for compressed oops.
Reviewed-by: ysr, jmasa
author | coleenp |
---|---|
date | Mon, 09 Jun 2008 11:51:19 -0400 |
parents | a61af66fc99e |
children | d1605aabd0a1 12eea04c8b06 |
comparison
equal
deleted
inserted
replaced
185:8759d37f2524 | 187:790e66e5fbac |
---|---|
20 * CA 95054 USA or visit www.sun.com if you need additional information or | 20 * CA 95054 USA or visit www.sun.com if you need additional information or |
21 * have any questions. | 21 * have any questions. |
22 * | 22 * |
23 */ | 23 */ |
24 | 24 |
25 // | |
26 // Free block maintenance for Concurrent Mark Sweep Generation | |
27 // | |
28 // The main data structure for free blocks are | |
29 // . an indexed array of small free blocks, and | |
30 // . a dictionary of large free blocks | |
31 // | |
32 | |
33 // No virtuals in FreeChunk (don't want any vtables). | |
34 | |
35 // A FreeChunk is merely a chunk that can be in a doubly linked list | |
36 // and has a size field. NOTE: FreeChunks are distinguished from allocated | |
37 // objects in two ways (by the sweeper). The second word (prev) has the | |
38 // LSB set to indicate a free chunk; allocated objects' klass() pointers | |
39 // don't have their LSB set. The corresponding bit in the CMSBitMap is | |
40 // set when the chunk is allocated. There are also blocks that "look free" | |
41 // but are not part of the free list and should not be coalesced into larger | |
42 // free blocks. These free blocks have their two LSB's set. | |
43 | |
44 class FreeChunk VALUE_OBJ_CLASS_SPEC { | |
45 friend class VMStructs; | |
46 FreeChunk* _next; | |
47 FreeChunk* _prev; | |
48 size_t _size; | |
49 | |
50 public: | |
51 NOT_PRODUCT(static const size_t header_size();) | |
52 // Returns "true" if the "wrd", which is required to be the second word | |
53 // of a block, indicates that the block represents a free chunk. | |
54 static bool secondWordIndicatesFreeChunk(intptr_t wrd) { | |
55 return (wrd & 0x1) == 0x1; | |
56 } | |
57 bool isFree() const { | |
58 return secondWordIndicatesFreeChunk((intptr_t)_prev); | |
59 } | |
60 bool cantCoalesce() const { return (((intptr_t)_prev) & 0x3) == 0x3; } | |
61 FreeChunk* next() const { return _next; } | |
62 FreeChunk* prev() const { return (FreeChunk*)(((intptr_t)_prev) & ~(0x3)); } | |
63 debug_only(void* prev_addr() const { return (void*)&_prev; }) | |
64 | |
65 void linkAfter(FreeChunk* ptr) { | |
66 linkNext(ptr); | |
67 if (ptr != NULL) ptr->linkPrev(this); | |
68 } | |
69 void linkAfterNonNull(FreeChunk* ptr) { | |
70 assert(ptr != NULL, "precondition violation"); | |
71 linkNext(ptr); | |
72 ptr->linkPrev(this); | |
73 } | |
74 void linkNext(FreeChunk* ptr) { _next = ptr; } | |
75 void linkPrev(FreeChunk* ptr) { _prev = (FreeChunk*)((intptr_t)ptr | 0x1); } | |
76 void clearPrev() { _prev = NULL; } | |
77 void clearNext() { _next = NULL; } | |
78 void dontCoalesce() { | |
79 // the block should be free | |
80 assert(isFree(), "Should look like a free block"); | |
81 _prev = (FreeChunk*)(((intptr_t)_prev) | 0x2); | |
82 } | |
83 void markFree() { _prev = (FreeChunk*)((intptr_t)_prev | 0x1); } | |
84 void markNotFree() { _prev = NULL; } | |
85 | |
86 size_t size() const { return _size; } | |
87 void setSize(size_t size) { _size = size; } | |
88 | |
89 // For volatile reads: | |
90 size_t* size_addr() { return &_size; } | |
91 | |
92 // Return the address past the end of this chunk | |
93 HeapWord* end() const { return ((HeapWord*) this) + _size; } | |
94 | |
95 // debugging | |
96 void verify() const PRODUCT_RETURN; | |
97 void verifyList() const PRODUCT_RETURN; | |
98 void mangleAllocated(size_t size) PRODUCT_RETURN; | |
99 void mangleFreed(size_t size) PRODUCT_RETURN; | |
100 }; | |
101 | |
102 // Alignment helpers etc. | |
103 #define numQuanta(x,y) ((x+y-1)/y) | |
104 enum AlignmentConstants { | |
105 MinChunkSize = numQuanta(sizeof(FreeChunk), MinObjAlignmentInBytes) * MinObjAlignment | |
106 }; | |
107 | 25 |
108 // A FreeBlockDictionary is an abstract superclass that will allow | 26 // A FreeBlockDictionary is an abstract superclass that will allow |
109 // a number of alternative implementations in the future. | 27 // a number of alternative implementations in the future. |
110 class FreeBlockDictionary: public CHeapObj { | 28 class FreeBlockDictionary: public CHeapObj { |
111 public: | 29 public: |