Mercurial > hg > truffle
comparison src/share/vm/gc_implementation/parallelScavenge/parMarkBitMap.hpp @ 10285:4868caa99ecf
8014339: Improve assert and remove some dead code from parMarkBitMap.hpp/cpp
Reviewed-by: stefank, tschatzl
author | brutisso |
---|---|
date | Mon, 13 May 2013 14:09:05 +0200 |
parents | 7b835924c31c |
children | 10f759898d40 |
comparison
equal
deleted
inserted
replaced
10284:7a95933197d0 | 10285:4868caa99ecf |
---|---|
24 | 24 |
25 #ifndef SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PARMARKBITMAP_HPP | 25 #ifndef SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PARMARKBITMAP_HPP |
26 #define SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PARMARKBITMAP_HPP | 26 #define SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PARMARKBITMAP_HPP |
27 | 27 |
28 #include "memory/memRegion.hpp" | 28 #include "memory/memRegion.hpp" |
29 #include "gc_implementation/parallelScavenge/psVirtualspace.hpp" | 29 #include "oops/oop.hpp" |
30 #include "utilities/bitMap.inline.hpp" | 30 #include "utilities/bitMap.hpp" |
31 | 31 |
32 class oopDesc; | |
33 class ParMarkBitMapClosure; | 32 class ParMarkBitMapClosure; |
33 class PSVirtualSpace; | |
34 | 34 |
35 class ParMarkBitMap: public CHeapObj<mtGC> | 35 class ParMarkBitMap: public CHeapObj<mtGC> |
36 { | 36 { |
37 public: | 37 public: |
38 typedef BitMap::idx_t idx_t; | 38 typedef BitMap::idx_t idx_t; |
39 | 39 |
40 // Values returned by the iterate() methods. | 40 // Values returned by the iterate() methods. |
41 enum IterationStatus { incomplete, complete, full, would_overflow }; | 41 enum IterationStatus { incomplete, complete, full, would_overflow }; |
42 | 42 |
43 inline ParMarkBitMap(); | 43 inline ParMarkBitMap(); |
44 inline ParMarkBitMap(MemRegion covered_region); | |
45 bool initialize(MemRegion covered_region); | 44 bool initialize(MemRegion covered_region); |
46 | 45 |
47 // Atomically mark an object as live. | 46 // Atomically mark an object as live. |
48 bool mark_obj(HeapWord* addr, size_t size); | 47 bool mark_obj(HeapWord* addr, size_t size); |
49 inline bool mark_obj(oop obj, int size); | 48 inline bool mark_obj(oop obj, int size); |
50 inline bool mark_obj(oop obj); | |
51 | 49 |
52 // Return whether the specified begin or end bit is set. | 50 // Return whether the specified begin or end bit is set. |
53 inline bool is_obj_beg(idx_t bit) const; | 51 inline bool is_obj_beg(idx_t bit) const; |
54 inline bool is_obj_end(idx_t bit) const; | 52 inline bool is_obj_end(idx_t bit) const; |
55 | 53 |
75 inline size_t obj_size(HeapWord* beg_addr, HeapWord* end_addr) const; | 73 inline size_t obj_size(HeapWord* beg_addr, HeapWord* end_addr) const; |
76 | 74 |
77 // Return the size in words of the object (a search is done for the end bit). | 75 // Return the size in words of the object (a search is done for the end bit). |
78 inline size_t obj_size(idx_t beg_bit) const; | 76 inline size_t obj_size(idx_t beg_bit) const; |
79 inline size_t obj_size(HeapWord* addr) const; | 77 inline size_t obj_size(HeapWord* addr) const; |
80 inline size_t obj_size(oop obj) const; | |
81 | |
82 // Synonyms for the above. | |
83 size_t obj_size_in_words(oop obj) const { return obj_size((HeapWord*)obj); } | |
84 size_t obj_size_in_words(HeapWord* addr) const { return obj_size(addr); } | |
85 | 78 |
86 // Apply live_closure to each live object that lies completely within the | 79 // Apply live_closure to each live object that lies completely within the |
87 // range [live_range_beg, live_range_end). This is used to iterate over the | 80 // range [live_range_beg, live_range_end). This is used to iterate over the |
88 // compacted region of the heap. Return values: | 81 // compacted region of the heap. Return values: |
89 // | 82 // |
122 ParMarkBitMapClosure* dead_closure, | 115 ParMarkBitMapClosure* dead_closure, |
123 HeapWord* range_beg, | 116 HeapWord* range_beg, |
124 HeapWord* range_end, | 117 HeapWord* range_end, |
125 HeapWord* dead_range_end) const; | 118 HeapWord* dead_range_end) const; |
126 | 119 |
127 // Return the number of live words in the range [beg_addr, end_addr) due to | 120 // Return the number of live words in the range [beg_addr, end_obj) due to |
128 // objects that start in the range. If a live object extends onto the range, | 121 // objects that start in the range. If a live object extends onto the range, |
129 // the caller must detect and account for any live words due to that object. | 122 // the caller must detect and account for any live words due to that object. |
130 // If a live object extends beyond the end of the range, only the words within | 123 // If a live object extends beyond the end of the range, only the words within |
131 // the range are included in the result. | 124 // the range are included in the result. The end of the range must be a live object, |
132 size_t live_words_in_range(HeapWord* beg_addr, HeapWord* end_addr) const; | 125 // which is the case when updating pointers. This allows a branch to be removed |
133 | |
134 // Same as the above, except the end of the range must be a live object, which | |
135 // is the case when updating pointers. This allows a branch to be removed | |
136 // from inside the loop. | 126 // from inside the loop. |
137 size_t live_words_in_range(HeapWord* beg_addr, oop end_obj) const; | 127 size_t live_words_in_range(HeapWord* beg_addr, oop end_obj) const; |
138 | 128 |
139 inline HeapWord* region_start() const; | 129 inline HeapWord* region_start() const; |
140 inline HeapWord* region_end() const; | 130 inline HeapWord* region_end() const; |
154 inline HeapWord* find_obj_end(HeapWord* beg, HeapWord* end) const; | 144 inline HeapWord* find_obj_end(HeapWord* beg, HeapWord* end) const; |
155 | 145 |
156 // Clear a range of bits or the entire bitmap (both begin and end bits are | 146 // Clear a range of bits or the entire bitmap (both begin and end bits are |
157 // cleared). | 147 // cleared). |
158 inline void clear_range(idx_t beg, idx_t end); | 148 inline void clear_range(idx_t beg, idx_t end); |
159 inline void clear() { clear_range(0, size()); } | |
160 | 149 |
161 // Return the number of bits required to represent the specified number of | 150 // Return the number of bits required to represent the specified number of |
162 // HeapWords, or the specified region. | 151 // HeapWords, or the specified region. |
163 static inline idx_t bits_required(size_t words); | 152 static inline idx_t bits_required(size_t words); |
164 static inline idx_t bits_required(MemRegion covered_region); | 153 static inline idx_t bits_required(MemRegion covered_region); |
165 static inline idx_t words_required(MemRegion covered_region); | |
166 | |
167 #ifndef PRODUCT | |
168 // CAS statistics. | |
169 size_t cas_tries() { return _cas_tries; } | |
170 size_t cas_retries() { return _cas_retries; } | |
171 size_t cas_by_another() { return _cas_by_another; } | |
172 | |
173 void reset_counters(); | |
174 #endif // #ifndef PRODUCT | |
175 | 154 |
176 void print_on_error(outputStream* st) const { | 155 void print_on_error(outputStream* st) const { |
177 st->print_cr("Marking Bits: (ParMarkBitMap*) " PTR_FORMAT, this); | 156 st->print_cr("Marking Bits: (ParMarkBitMap*) " PTR_FORMAT, this); |
178 _beg_bits.print_on_error(st, " Begin Bits: "); | 157 _beg_bits.print_on_error(st, " Begin Bits: "); |
179 _end_bits.print_on_error(st, " End Bits: "); | 158 _end_bits.print_on_error(st, " End Bits: "); |
195 HeapWord* _region_start; | 174 HeapWord* _region_start; |
196 size_t _region_size; | 175 size_t _region_size; |
197 BitMap _beg_bits; | 176 BitMap _beg_bits; |
198 BitMap _end_bits; | 177 BitMap _end_bits; |
199 PSVirtualSpace* _virtual_space; | 178 PSVirtualSpace* _virtual_space; |
200 | |
201 #ifndef PRODUCT | |
202 size_t _cas_tries; | |
203 size_t _cas_retries; | |
204 size_t _cas_by_another; | |
205 #endif // #ifndef PRODUCT | |
206 }; | 179 }; |
207 | 180 |
208 inline ParMarkBitMap::ParMarkBitMap(): | 181 inline ParMarkBitMap::ParMarkBitMap(): |
209 _beg_bits(), | 182 _beg_bits(), _end_bits(), _region_start(NULL), _region_size(0), _virtual_space(NULL) |
210 _end_bits() | 183 { } |
211 { | |
212 _region_start = 0; | |
213 _virtual_space = 0; | |
214 } | |
215 | |
216 inline ParMarkBitMap::ParMarkBitMap(MemRegion covered_region): | |
217 _beg_bits(), | |
218 _end_bits() | |
219 { | |
220 initialize(covered_region); | |
221 } | |
222 | 184 |
223 inline void ParMarkBitMap::clear_range(idx_t beg, idx_t end) | 185 inline void ParMarkBitMap::clear_range(idx_t beg, idx_t end) |
224 { | 186 { |
225 _beg_bits.clear_range(beg, end); | 187 _beg_bits.clear_range(beg, end); |
226 _end_bits.clear_range(beg, end); | 188 _end_bits.clear_range(beg, end); |
236 | 198 |
237 inline ParMarkBitMap::idx_t | 199 inline ParMarkBitMap::idx_t |
238 ParMarkBitMap::bits_required(MemRegion covered_region) | 200 ParMarkBitMap::bits_required(MemRegion covered_region) |
239 { | 201 { |
240 return bits_required(covered_region.word_size()); | 202 return bits_required(covered_region.word_size()); |
241 } | |
242 | |
243 inline ParMarkBitMap::idx_t | |
244 ParMarkBitMap::words_required(MemRegion covered_region) | |
245 { | |
246 return bits_required(covered_region) / BitsPerWord; | |
247 } | 203 } |
248 | 204 |
249 inline HeapWord* | 205 inline HeapWord* |
250 ParMarkBitMap::region_start() const | 206 ParMarkBitMap::region_start() const |
251 { | 207 { |
346 } | 302 } |
347 | 303 |
348 inline size_t ParMarkBitMap::obj_size(HeapWord* addr) const | 304 inline size_t ParMarkBitMap::obj_size(HeapWord* addr) const |
349 { | 305 { |
350 return obj_size(addr_to_bit(addr)); | 306 return obj_size(addr_to_bit(addr)); |
351 } | |
352 | |
353 inline size_t ParMarkBitMap::obj_size(oop obj) const | |
354 { | |
355 return obj_size((HeapWord*)obj); | |
356 } | 307 } |
357 | 308 |
358 inline ParMarkBitMap::IterationStatus | 309 inline ParMarkBitMap::IterationStatus |
359 ParMarkBitMap::iterate(ParMarkBitMapClosure* live_closure, | 310 ParMarkBitMap::iterate(ParMarkBitMapClosure* live_closure, |
360 HeapWord* range_beg, | 311 HeapWord* range_beg, |
433 assert(bit <= _beg_bits.size(), "bit out of range"); | 384 assert(bit <= _beg_bits.size(), "bit out of range"); |
434 } | 385 } |
435 | 386 |
436 inline void ParMarkBitMap::verify_addr(HeapWord* addr) const { | 387 inline void ParMarkBitMap::verify_addr(HeapWord* addr) const { |
437 // Allow one past the last valid address; useful for loop bounds. | 388 // Allow one past the last valid address; useful for loop bounds. |
438 assert(addr >= region_start(), "addr too small"); | 389 assert(addr >= region_start(), |
439 assert(addr <= region_start() + region_size(), "addr too big"); | 390 err_msg("addr too small, addr: " PTR_FORMAT " region start: " PTR_FORMAT, addr, region_start())); |
391 assert(addr <= region_end(), | |
392 err_msg("addr too big, addr: " PTR_FORMAT " region end: " PTR_FORMAT, addr, region_end())); | |
440 } | 393 } |
441 #endif // #ifdef ASSERT | 394 #endif // #ifdef ASSERT |
442 | 395 |
443 #endif // SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PARMARKBITMAP_HPP | 396 #endif // SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PARMARKBITMAP_HPP |