author | ehelin |
Tue, 18 Mar 2014 09:03:28 +0100 | |
changeset 23470 | ff2a7ea4225d |
parent 22882 | 195c8f70d605 |
child 23508 | 3b15250ea28f |
permissions | -rw-r--r-- |
1 | 1 |
/* |
15605 | 2 |
* Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. |
1 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5343
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5343
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5343
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#ifndef SHARE_VM_GC_IMPLEMENTATION_CONCURRENTMARKSWEEP_CONCURRENTMARKSWEEPGENERATION_HPP |
26 |
#define SHARE_VM_GC_IMPLEMENTATION_CONCURRENTMARKSWEEP_CONCURRENTMARKSWEEPGENERATION_HPP |
|
27 |
||
18025 | 28 |
#include "gc_implementation/shared/gcHeapSummary.hpp" |
7397 | 29 |
#include "gc_implementation/shared/gSpaceCounters.hpp" |
30 |
#include "gc_implementation/shared/gcStats.hpp" |
|
18025 | 31 |
#include "gc_implementation/shared/gcWhen.hpp" |
7397 | 32 |
#include "gc_implementation/shared/generationCounters.hpp" |
12507 | 33 |
#include "memory/freeBlockDictionary.hpp" |
7397 | 34 |
#include "memory/generation.hpp" |
35 |
#include "runtime/mutexLocker.hpp" |
|
36 |
#include "runtime/virtualspace.hpp" |
|
37 |
#include "services/memoryService.hpp" |
|
38 |
#include "utilities/bitMap.inline.hpp" |
|
39 |
#include "utilities/stack.inline.hpp" |
|
40 |
#include "utilities/taskqueue.hpp" |
|
41 |
#include "utilities/yieldingWorkgroup.hpp" |
|
42 |
||
1 | 43 |
// ConcurrentMarkSweepGeneration is in support of a concurrent |
44 |
// mark-sweep old generation in the Detlefs-Printezis--Boehm-Demers-Schenker |
|
45 |
// style. We assume, for now, that this generation is always the |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
46 |
// seniormost generation and for simplicity |
1 | 47 |
// in the first implementation, that this generation is a single compactible |
48 |
// space. Neither of these restrictions appears essential, and will be |
|
49 |
// relaxed in the future when more time is available to implement the |
|
50 |
// greater generality (and there's a need for it). |
|
51 |
// |
|
52 |
// Concurrent mode failures are currently handled by |
|
53 |
// means of a sliding mark-compact. |
|
54 |
||
55 |
class CMSAdaptiveSizePolicy; |
|
56 |
class CMSConcMarkingTask; |
|
57 |
class CMSGCAdaptivePolicyCounters; |
|
18025 | 58 |
class CMSTracer; |
59 |
class ConcurrentGCTimer; |
|
1 | 60 |
class ConcurrentMarkSweepGeneration; |
61 |
class ConcurrentMarkSweepPolicy; |
|
62 |
class ConcurrentMarkSweepThread; |
|
63 |
class CompactibleFreeListSpace; |
|
64 |
class FreeChunk; |
|
65 |
class PromotionInfo; |
|
66 |
class ScanMarkedObjectsAgainCarefullyClosure; |
|
16681
d64161ca3e3c
8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents:
15605
diff
changeset
|
67 |
class TenuredGeneration; |
18025 | 68 |
class SerialOldTracer; |
1 | 69 |
|
70 |
// A generic CMS bit map. It's the basis for both the CMS marking bit map |
|
71 |
// as well as for the mod union table (in each case only a subset of the |
|
72 |
// methods are used). This is essentially a wrapper around the BitMap class, |
|
73 |
// with one bit per (1<<_shifter) HeapWords. (i.e. for the marking bit map, |
|
74 |
// we have _shifter == 0. and for the mod union table we have |
|
75 |
// shifter == CardTableModRefBS::card_shift - LogHeapWordSize.) |
|
76 |
// XXX 64-bit issues in BitMap? |
|
77 |
class CMSBitMap VALUE_OBJ_CLASS_SPEC { |
|
78 |
friend class VMStructs; |
|
79 |
||
80 |
HeapWord* _bmStartWord; // base address of range covered by map |
|
81 |
size_t _bmWordSize; // map size (in #HeapWords covered) |
|
82 |
const int _shifter; // shifts to convert HeapWord to bit position |
|
83 |
VirtualSpace _virtual_space; // underlying the bit map |
|
84 |
BitMap _bm; // the bit map itself |
|
85 |
public: |
|
86 |
Mutex* const _lock; // mutex protecting _bm; |
|
87 |
||
88 |
public: |
|
89 |
// constructor |
|
90 |
CMSBitMap(int shifter, int mutex_rank, const char* mutex_name); |
|
91 |
||
92 |
// allocates the actual storage for the map |
|
93 |
bool allocate(MemRegion mr); |
|
94 |
// field getter |
|
95 |
Mutex* lock() const { return _lock; } |
|
96 |
// locking verifier convenience function |
|
97 |
void assert_locked() const PRODUCT_RETURN; |
|
98 |
||
99 |
// inquiries |
|
100 |
HeapWord* startWord() const { return _bmStartWord; } |
|
101 |
size_t sizeInWords() const { return _bmWordSize; } |
|
102 |
size_t sizeInBits() const { return _bm.size(); } |
|
103 |
// the following is one past the last word in space |
|
104 |
HeapWord* endWord() const { return _bmStartWord + _bmWordSize; } |
|
105 |
||
106 |
// reading marks |
|
107 |
bool isMarked(HeapWord* addr) const; |
|
108 |
bool par_isMarked(HeapWord* addr) const; // do not lock checks |
|
109 |
bool isUnmarked(HeapWord* addr) const; |
|
110 |
bool isAllClear() const; |
|
111 |
||
112 |
// writing marks |
|
113 |
void mark(HeapWord* addr); |
|
114 |
// For marking by parallel GC threads; |
|
115 |
// returns true if we did, false if another thread did |
|
116 |
bool par_mark(HeapWord* addr); |
|
117 |
||
118 |
void mark_range(MemRegion mr); |
|
119 |
void par_mark_range(MemRegion mr); |
|
120 |
void mark_large_range(MemRegion mr); |
|
121 |
void par_mark_large_range(MemRegion mr); |
|
122 |
void par_clear(HeapWord* addr); // For unmarking by parallel GC threads. |
|
123 |
void clear_range(MemRegion mr); |
|
124 |
void par_clear_range(MemRegion mr); |
|
125 |
void clear_large_range(MemRegion mr); |
|
126 |
void par_clear_large_range(MemRegion mr); |
|
127 |
void clear_all(); |
|
128 |
void clear_all_incrementally(); // Not yet implemented!! |
|
129 |
||
130 |
NOT_PRODUCT( |
|
131 |
// checks the memory region for validity |
|
132 |
void region_invariant(MemRegion mr); |
|
133 |
) |
|
134 |
||
135 |
// iteration |
|
136 |
void iterate(BitMapClosure* cl) { |
|
137 |
_bm.iterate(cl); |
|
138 |
} |
|
139 |
void iterate(BitMapClosure* cl, HeapWord* left, HeapWord* right); |
|
140 |
void dirty_range_iterate_clear(MemRegionClosure* cl); |
|
141 |
void dirty_range_iterate_clear(MemRegion mr, MemRegionClosure* cl); |
|
142 |
||
143 |
// auxiliary support for iteration |
|
144 |
HeapWord* getNextMarkedWordAddress(HeapWord* addr) const; |
|
145 |
HeapWord* getNextMarkedWordAddress(HeapWord* start_addr, |
|
146 |
HeapWord* end_addr) const; |
|
147 |
HeapWord* getNextUnmarkedWordAddress(HeapWord* addr) const; |
|
148 |
HeapWord* getNextUnmarkedWordAddress(HeapWord* start_addr, |
|
149 |
HeapWord* end_addr) const; |
|
150 |
MemRegion getAndClearMarkedRegion(HeapWord* addr); |
|
151 |
MemRegion getAndClearMarkedRegion(HeapWord* start_addr, |
|
152 |
HeapWord* end_addr); |
|
153 |
||
154 |
// conversion utilities |
|
155 |
HeapWord* offsetToHeapWord(size_t offset) const; |
|
156 |
size_t heapWordToOffset(HeapWord* addr) const; |
|
157 |
size_t heapWordDiffToOffsetDiff(size_t diff) const; |
|
158 |
||
16685
41c34debcde0
8011872: Include Bit Map addresses in the hs_err files
stefank
parents:
16681
diff
changeset
|
159 |
void print_on_error(outputStream* st, const char* prefix) const; |
41c34debcde0
8011872: Include Bit Map addresses in the hs_err files
stefank
parents:
16681
diff
changeset
|
160 |
|
1 | 161 |
// debugging |
162 |
// is this address range covered by the bit-map? |
|
163 |
NOT_PRODUCT( |
|
164 |
bool covers(MemRegion mr) const; |
|
165 |
bool covers(HeapWord* start, size_t size = 0) const; |
|
166 |
) |
|
167 |
void verifyNoOneBitsInRange(HeapWord* left, HeapWord* right) PRODUCT_RETURN; |
|
168 |
}; |
|
169 |
||
170 |
// Represents a marking stack used by the CMS collector. |
|
171 |
// Ideally this should be GrowableArray<> just like MSC's marking stack(s). |
|
13195 | 172 |
class CMSMarkStack: public CHeapObj<mtGC> { |
1 | 173 |
// |
22551 | 174 |
friend class CMSCollector; // To get at expansion stats further below. |
1 | 175 |
// |
176 |
||
22551 | 177 |
VirtualSpace _virtual_space; // Space for the stack |
178 |
oop* _base; // Bottom of stack |
|
179 |
size_t _index; // One more than last occupied index |
|
180 |
size_t _capacity; // Max #elements |
|
181 |
Mutex _par_lock; // An advisory lock used in case of parallel access |
|
182 |
NOT_PRODUCT(size_t _max_depth;) // Max depth plumbed during run |
|
1 | 183 |
|
184 |
protected: |
|
22551 | 185 |
size_t _hit_limit; // We hit max stack size limit |
186 |
size_t _failed_double; // We failed expansion before hitting limit |
|
1 | 187 |
|
188 |
public: |
|
189 |
CMSMarkStack(): |
|
190 |
_par_lock(Mutex::event, "CMSMarkStack._par_lock", true), |
|
191 |
_hit_limit(0), |
|
192 |
_failed_double(0) {} |
|
193 |
||
194 |
bool allocate(size_t size); |
|
195 |
||
196 |
size_t capacity() const { return _capacity; } |
|
197 |
||
198 |
oop pop() { |
|
199 |
if (!isEmpty()) { |
|
200 |
return _base[--_index] ; |
|
201 |
} |
|
202 |
return NULL; |
|
203 |
} |
|
204 |
||
205 |
bool push(oop ptr) { |
|
206 |
if (isFull()) { |
|
207 |
return false; |
|
208 |
} else { |
|
209 |
_base[_index++] = ptr; |
|
210 |
NOT_PRODUCT(_max_depth = MAX2(_max_depth, _index)); |
|
211 |
return true; |
|
212 |
} |
|
213 |
} |
|
214 |
||
215 |
bool isEmpty() const { return _index == 0; } |
|
216 |
bool isFull() const { |
|
217 |
assert(_index <= _capacity, "buffer overflow"); |
|
218 |
return _index == _capacity; |
|
219 |
} |
|
220 |
||
221 |
size_t length() { return _index; } |
|
222 |
||
223 |
// "Parallel versions" of some of the above |
|
224 |
oop par_pop() { |
|
225 |
// lock and pop |
|
226 |
MutexLockerEx x(&_par_lock, Mutex::_no_safepoint_check_flag); |
|
227 |
return pop(); |
|
228 |
} |
|
229 |
||
230 |
bool par_push(oop ptr) { |
|
231 |
// lock and push |
|
232 |
MutexLockerEx x(&_par_lock, Mutex::_no_safepoint_check_flag); |
|
233 |
return push(ptr); |
|
234 |
} |
|
235 |
||
236 |
// Forcibly reset the stack, losing all of its contents. |
|
237 |
void reset() { |
|
238 |
_index = 0; |
|
239 |
} |
|
240 |
||
22551 | 241 |
// Expand the stack, typically in response to an overflow condition. |
1 | 242 |
void expand(); |
243 |
||
244 |
// Compute the least valued stack element. |
|
245 |
oop least_value(HeapWord* low) { |
|
246 |
oop least = (oop)low; |
|
247 |
for (size_t i = 0; i < _index; i++) { |
|
248 |
least = MIN2(least, _base[i]); |
|
249 |
} |
|
250 |
return least; |
|
251 |
} |
|
252 |
||
22551 | 253 |
// Exposed here to allow stack expansion in || case. |
1 | 254 |
Mutex* par_lock() { return &_par_lock; } |
255 |
}; |
|
256 |
||
257 |
class CardTableRS; |
|
258 |
class CMSParGCThreadState; |
|
259 |
||
260 |
class ModUnionClosure: public MemRegionClosure { |
|
261 |
protected: |
|
262 |
CMSBitMap* _t; |
|
263 |
public: |
|
264 |
ModUnionClosure(CMSBitMap* t): _t(t) { } |
|
265 |
void do_MemRegion(MemRegion mr); |
|
266 |
}; |
|
267 |
||
268 |
class ModUnionClosurePar: public ModUnionClosure { |
|
269 |
public: |
|
270 |
ModUnionClosurePar(CMSBitMap* t): ModUnionClosure(t) { } |
|
271 |
void do_MemRegion(MemRegion mr); |
|
272 |
}; |
|
273 |
||
274 |
// Survivor Chunk Array in support of parallelization of |
|
275 |
// Survivor Space rescan. |
|
13195 | 276 |
class ChunkArray: public CHeapObj<mtGC> { |
1 | 277 |
size_t _index; |
278 |
size_t _capacity; |
|
6423
1ef0582c27c2
6910183: CMS: assert(_index < capacity(),"_index out of bounds")
ysr
parents:
6258
diff
changeset
|
279 |
size_t _overflows; |
1 | 280 |
HeapWord** _array; // storage for array |
281 |
||
282 |
public: |
|
6423
1ef0582c27c2
6910183: CMS: assert(_index < capacity(),"_index out of bounds")
ysr
parents:
6258
diff
changeset
|
283 |
ChunkArray() : _index(0), _capacity(0), _overflows(0), _array(NULL) {} |
1 | 284 |
ChunkArray(HeapWord** a, size_t c): |
6423
1ef0582c27c2
6910183: CMS: assert(_index < capacity(),"_index out of bounds")
ysr
parents:
6258
diff
changeset
|
285 |
_index(0), _capacity(c), _overflows(0), _array(a) {} |
1 | 286 |
|
287 |
HeapWord** array() { return _array; } |
|
288 |
void set_array(HeapWord** a) { _array = a; } |
|
289 |
||
290 |
size_t capacity() { return _capacity; } |
|
291 |
void set_capacity(size_t c) { _capacity = c; } |
|
292 |
||
293 |
size_t end() { |
|
6423
1ef0582c27c2
6910183: CMS: assert(_index < capacity(),"_index out of bounds")
ysr
parents:
6258
diff
changeset
|
294 |
assert(_index <= capacity(), |
1ef0582c27c2
6910183: CMS: assert(_index < capacity(),"_index out of bounds")
ysr
parents:
6258
diff
changeset
|
295 |
err_msg("_index (" SIZE_FORMAT ") > _capacity (" SIZE_FORMAT "): out of bounds", |
1ef0582c27c2
6910183: CMS: assert(_index < capacity(),"_index out of bounds")
ysr
parents:
6258
diff
changeset
|
296 |
_index, _capacity)); |
1 | 297 |
return _index; |
298 |
} // exclusive |
|
299 |
||
300 |
HeapWord* nth(size_t n) { |
|
301 |
assert(n < end(), "Out of bounds access"); |
|
302 |
return _array[n]; |
|
303 |
} |
|
304 |
||
305 |
void reset() { |
|
306 |
_index = 0; |
|
6423
1ef0582c27c2
6910183: CMS: assert(_index < capacity(),"_index out of bounds")
ysr
parents:
6258
diff
changeset
|
307 |
if (_overflows > 0 && PrintCMSStatistics > 1) { |
1ef0582c27c2
6910183: CMS: assert(_index < capacity(),"_index out of bounds")
ysr
parents:
6258
diff
changeset
|
308 |
warning("CMS: ChunkArray[" SIZE_FORMAT "] overflowed " SIZE_FORMAT " times", |
1ef0582c27c2
6910183: CMS: assert(_index < capacity(),"_index out of bounds")
ysr
parents:
6258
diff
changeset
|
309 |
_capacity, _overflows); |
1ef0582c27c2
6910183: CMS: assert(_index < capacity(),"_index out of bounds")
ysr
parents:
6258
diff
changeset
|
310 |
} |
1ef0582c27c2
6910183: CMS: assert(_index < capacity(),"_index out of bounds")
ysr
parents:
6258
diff
changeset
|
311 |
_overflows = 0; |
1 | 312 |
} |
313 |
||
314 |
void record_sample(HeapWord* p, size_t sz) { |
|
315 |
// For now we do not do anything with the size |
|
316 |
if (_index < _capacity) { |
|
317 |
_array[_index++] = p; |
|
6423
1ef0582c27c2
6910183: CMS: assert(_index < capacity(),"_index out of bounds")
ysr
parents:
6258
diff
changeset
|
318 |
} else { |
1ef0582c27c2
6910183: CMS: assert(_index < capacity(),"_index out of bounds")
ysr
parents:
6258
diff
changeset
|
319 |
++_overflows; |
1ef0582c27c2
6910183: CMS: assert(_index < capacity(),"_index out of bounds")
ysr
parents:
6258
diff
changeset
|
320 |
assert(_index == _capacity, |
1ef0582c27c2
6910183: CMS: assert(_index < capacity(),"_index out of bounds")
ysr
parents:
6258
diff
changeset
|
321 |
err_msg("_index (" SIZE_FORMAT ") > _capacity (" SIZE_FORMAT |
1ef0582c27c2
6910183: CMS: assert(_index < capacity(),"_index out of bounds")
ysr
parents:
6258
diff
changeset
|
322 |
"): out of bounds at overflow#" SIZE_FORMAT, |
1ef0582c27c2
6910183: CMS: assert(_index < capacity(),"_index out of bounds")
ysr
parents:
6258
diff
changeset
|
323 |
_index, _capacity, _overflows)); |
1 | 324 |
} |
325 |
} |
|
326 |
}; |
|
327 |
||
328 |
// |
|
329 |
// Timing, allocation and promotion statistics for gc scheduling and incremental |
|
330 |
// mode pacing. Most statistics are exponential averages. |
|
331 |
// |
|
332 |
class CMSStats VALUE_OBJ_CLASS_SPEC { |
|
333 |
private: |
|
334 |
ConcurrentMarkSweepGeneration* const _cms_gen; // The cms (old) gen. |
|
335 |
||
336 |
// The following are exponential averages with factor alpha: |
|
337 |
// avg = (100 - alpha) * avg + alpha * cur_sample |
|
338 |
// |
|
339 |
// The durations measure: end_time[n] - start_time[n] |
|
340 |
// The periods measure: start_time[n] - start_time[n-1] |
|
341 |
// |
|
342 |
// The cms period and duration include only concurrent collections; time spent |
|
343 |
// in foreground cms collections due to System.gc() or because of a failure to |
|
344 |
// keep up are not included. |
|
345 |
// |
|
346 |
// There are 3 alphas to "bootstrap" the statistics. The _saved_alpha is the |
|
347 |
// real value, but is used only after the first period. A value of 100 is |
|
348 |
// used for the first sample so it gets the entire weight. |
|
349 |
unsigned int _saved_alpha; // 0-100 |
|
350 |
unsigned int _gc0_alpha; |
|
351 |
unsigned int _cms_alpha; |
|
352 |
||
353 |
double _gc0_duration; |
|
354 |
double _gc0_period; |
|
355 |
size_t _gc0_promoted; // bytes promoted per gc0 |
|
356 |
double _cms_duration; |
|
357 |
double _cms_duration_pre_sweep; // time from initiation to start of sweep |
|
358 |
double _cms_duration_per_mb; |
|
359 |
double _cms_period; |
|
360 |
size_t _cms_allocated; // bytes of direct allocation per gc0 period |
|
361 |
||
362 |
// Timers. |
|
363 |
elapsedTimer _cms_timer; |
|
364 |
TimeStamp _gc0_begin_time; |
|
365 |
TimeStamp _cms_begin_time; |
|
366 |
TimeStamp _cms_end_time; |
|
367 |
||
368 |
// Snapshots of the amount used in the CMS generation. |
|
369 |
size_t _cms_used_at_gc0_begin; |
|
370 |
size_t _cms_used_at_gc0_end; |
|
371 |
size_t _cms_used_at_cms_begin; |
|
372 |
||
373 |
// Used to prevent the duty cycle from being reduced in the middle of a cms |
|
374 |
// cycle. |
|
375 |
bool _allow_duty_cycle_reduction; |
|
376 |
||
377 |
enum { |
|
378 |
_GC0_VALID = 0x1, |
|
379 |
_CMS_VALID = 0x2, |
|
380 |
_ALL_VALID = _GC0_VALID | _CMS_VALID |
|
381 |
}; |
|
382 |
||
383 |
unsigned int _valid_bits; |
|
384 |
||
385 |
unsigned int _icms_duty_cycle; // icms duty cycle (0-100). |
|
386 |
||
387 |
protected: |
|
388 |
||
389 |
// Return a duty cycle that avoids wild oscillations, by limiting the amount |
|
390 |
// of change between old_duty_cycle and new_duty_cycle (the latter is treated |
|
391 |
// as a recommended value). |
|
392 |
static unsigned int icms_damped_duty_cycle(unsigned int old_duty_cycle, |
|
393 |
unsigned int new_duty_cycle); |
|
394 |
unsigned int icms_update_duty_cycle_impl(); |
|
395 |
||
4574
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
3690
diff
changeset
|
396 |
// In support of adjusting of cms trigger ratios based on history |
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
3690
diff
changeset
|
397 |
// of concurrent mode failure. |
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
3690
diff
changeset
|
398 |
double cms_free_adjustment_factor(size_t free) const; |
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
3690
diff
changeset
|
399 |
void adjust_cms_free_adjustment_factor(bool fail, size_t free); |
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
3690
diff
changeset
|
400 |
|
1 | 401 |
public: |
402 |
CMSStats(ConcurrentMarkSweepGeneration* cms_gen, |
|
403 |
unsigned int alpha = CMSExpAvgFactor); |
|
404 |
||
405 |
// Whether or not the statistics contain valid data; higher level statistics |
|
406 |
// cannot be called until this returns true (they require at least one young |
|
407 |
// gen and one cms cycle to have completed). |
|
408 |
bool valid() const; |
|
409 |
||
410 |
// Record statistics. |
|
411 |
void record_gc0_begin(); |
|
412 |
void record_gc0_end(size_t cms_gen_bytes_used); |
|
413 |
void record_cms_begin(); |
|
414 |
void record_cms_end(); |
|
415 |
||
416 |
// Allow management of the cms timer, which must be stopped/started around |
|
417 |
// yield points. |
|
418 |
elapsedTimer& cms_timer() { return _cms_timer; } |
|
419 |
void start_cms_timer() { _cms_timer.start(); } |
|
420 |
void stop_cms_timer() { _cms_timer.stop(); } |
|
421 |
||
422 |
// Basic statistics; units are seconds or bytes. |
|
423 |
double gc0_period() const { return _gc0_period; } |
|
424 |
double gc0_duration() const { return _gc0_duration; } |
|
425 |
size_t gc0_promoted() const { return _gc0_promoted; } |
|
426 |
double cms_period() const { return _cms_period; } |
|
427 |
double cms_duration() const { return _cms_duration; } |
|
428 |
double cms_duration_per_mb() const { return _cms_duration_per_mb; } |
|
429 |
size_t cms_allocated() const { return _cms_allocated; } |
|
430 |
||
431 |
size_t cms_used_at_gc0_end() const { return _cms_used_at_gc0_end;} |
|
432 |
||
433 |
// Seconds since the last background cms cycle began or ended. |
|
434 |
double cms_time_since_begin() const; |
|
435 |
double cms_time_since_end() const; |
|
436 |
||
437 |
// Higher level statistics--caller must check that valid() returns true before |
|
438 |
// calling. |
|
439 |
||
440 |
// Returns bytes promoted per second of wall clock time. |
|
441 |
double promotion_rate() const; |
|
442 |
||
443 |
// Returns bytes directly allocated per second of wall clock time. |
|
444 |
double cms_allocation_rate() const; |
|
445 |
||
446 |
// Rate at which space in the cms generation is being consumed (sum of the |
|
447 |
// above two). |
|
448 |
double cms_consumption_rate() const; |
|
449 |
||
450 |
// Returns an estimate of the number of seconds until the cms generation will |
|
451 |
// fill up, assuming no collection work is done. |
|
452 |
double time_until_cms_gen_full() const; |
|
453 |
||
454 |
// Returns an estimate of the number of seconds remaining until |
|
455 |
// the cms generation collection should start. |
|
456 |
double time_until_cms_start() const; |
|
457 |
||
458 |
// End of higher level statistics. |
|
459 |
||
460 |
// Returns the cms incremental mode duty cycle, as a percentage (0-100). |
|
461 |
unsigned int icms_duty_cycle() const { return _icms_duty_cycle; } |
|
462 |
||
463 |
// Update the duty cycle and return the new value. |
|
464 |
unsigned int icms_update_duty_cycle(); |
|
465 |
||
466 |
// Debugging. |
|
467 |
void print_on(outputStream* st) const PRODUCT_RETURN; |
|
468 |
void print() const { print_on(gclog_or_tty); } |
|
469 |
}; |
|
470 |
||
471 |
// A closure related to weak references processing which |
|
472 |
// we embed in the CMSCollector, since we need to pass |
|
473 |
// it to the reference processor for secondary filtering |
|
474 |
// of references based on reachability of referent; |
|
475 |
// see role of _is_alive_non_header closure in the |
|
476 |
// ReferenceProcessor class. |
|
477 |
// For objects in the CMS generation, this closure checks |
|
478 |
// if the object is "live" (reachable). Used in weak |
|
479 |
// reference processing. |
|
480 |
class CMSIsAliveClosure: public BoolObjectClosure { |
|
390
2e094c1be4af
6662086: 6u4+, 7b11+: CMS never clears referents when -XX:+ParallelRefProcEnabled
ysr
parents:
360
diff
changeset
|
481 |
const MemRegion _span; |
1 | 482 |
const CMSBitMap* _bit_map; |
483 |
||
484 |
friend class CMSCollector; |
|
485 |
public: |
|
486 |
CMSIsAliveClosure(MemRegion span, |
|
487 |
CMSBitMap* bit_map): |
|
488 |
_span(span), |
|
390
2e094c1be4af
6662086: 6u4+, 7b11+: CMS never clears referents when -XX:+ParallelRefProcEnabled
ysr
parents:
360
diff
changeset
|
489 |
_bit_map(bit_map) { |
2e094c1be4af
6662086: 6u4+, 7b11+: CMS never clears referents when -XX:+ParallelRefProcEnabled
ysr
parents:
360
diff
changeset
|
490 |
assert(!span.is_empty(), "Empty span could spell trouble"); |
2e094c1be4af
6662086: 6u4+, 7b11+: CMS never clears referents when -XX:+ParallelRefProcEnabled
ysr
parents:
360
diff
changeset
|
491 |
} |
2e094c1be4af
6662086: 6u4+, 7b11+: CMS never clears referents when -XX:+ParallelRefProcEnabled
ysr
parents:
360
diff
changeset
|
492 |
|
1 | 493 |
bool do_object_b(oop obj); |
494 |
}; |
|
495 |
||
496 |
||
497 |
// Implements AbstractRefProcTaskExecutor for CMS. |
|
498 |
class CMSRefProcTaskExecutor: public AbstractRefProcTaskExecutor { |
|
499 |
public: |
|
500 |
||
501 |
CMSRefProcTaskExecutor(CMSCollector& collector) |
|
502 |
: _collector(collector) |
|
503 |
{ } |
|
504 |
||
505 |
// Executes a task using worker threads. |
|
506 |
virtual void execute(ProcessTask& task); |
|
507 |
virtual void execute(EnqueueTask& task); |
|
508 |
private: |
|
509 |
CMSCollector& _collector; |
|
510 |
}; |
|
511 |
||
512 |
||
13195 | 513 |
class CMSCollector: public CHeapObj<mtGC> { |
1 | 514 |
friend class VMStructs; |
515 |
friend class ConcurrentMarkSweepThread; |
|
516 |
friend class ConcurrentMarkSweepGeneration; |
|
517 |
friend class CompactibleFreeListSpace; |
|
18996 | 518 |
friend class CMSParMarkTask; |
519 |
friend class CMSParInitialMarkTask; |
|
1 | 520 |
friend class CMSParRemarkTask; |
521 |
friend class CMSConcMarkingTask; |
|
522 |
friend class CMSRefProcTaskProxy; |
|
523 |
friend class CMSRefProcTaskExecutor; |
|
524 |
friend class ScanMarkedObjectsAgainCarefullyClosure; // for sampling eden |
|
525 |
friend class SurvivorSpacePrecleanClosure; // --- ditto ------- |
|
526 |
friend class PushOrMarkClosure; // to access _restart_addr |
|
527 |
friend class Par_PushOrMarkClosure; // to access _restart_addr |
|
528 |
friend class MarkFromRootsClosure; // -- ditto -- |
|
529 |
// ... and for clearing cards |
|
530 |
friend class Par_MarkFromRootsClosure; // to access _restart_addr |
|
531 |
// ... and for clearing cards |
|
532 |
friend class Par_ConcMarkingClosure; // to access _restart_addr etc. |
|
533 |
friend class MarkFromRootsVerifyClosure; // to access _restart_addr |
|
534 |
friend class PushAndMarkVerifyClosure; // -- ditto -- |
|
535 |
friend class MarkRefsIntoAndScanClosure; // to access _overflow_list |
|
536 |
friend class PushAndMarkClosure; // -- ditto -- |
|
537 |
friend class Par_PushAndMarkClosure; // -- ditto -- |
|
538 |
friend class CMSKeepAliveClosure; // -- ditto -- |
|
539 |
friend class CMSDrainMarkingStackClosure; // -- ditto -- |
|
540 |
friend class CMSInnerParMarkAndPushClosure; // -- ditto -- |
|
541 |
NOT_PRODUCT(friend class ScanMarkedObjectsAgainClosure;) // assertion on _overflow_list |
|
542 |
friend class ReleaseForegroundGC; // to access _foregroundGCShouldWait |
|
543 |
friend class VM_CMS_Operation; |
|
544 |
friend class VM_CMS_Initial_Mark; |
|
545 |
friend class VM_CMS_Final_Remark; |
|
6245
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
546 |
friend class TraceCMSMemoryManagerStats; |
1 | 547 |
|
548 |
private: |
|
549 |
jlong _time_of_last_gc; |
|
550 |
void update_time_of_last_gc(jlong now) { |
|
551 |
_time_of_last_gc = now; |
|
552 |
} |
|
553 |
||
554 |
OopTaskQueueSet* _task_queues; |
|
555 |
||
556 |
// Overflow list of grey objects, threaded through mark-word |
|
557 |
// Manipulated with CAS in the parallel/multi-threaded case. |
|
558 |
oop _overflow_list; |
|
559 |
// The following array-pair keeps track of mark words |
|
22551 | 560 |
// displaced for accommodating overflow list above. |
1 | 561 |
// This code will likely be revisited under RFE#4922830. |
13195 | 562 |
Stack<oop, mtGC> _preserved_oop_stack; |
563 |
Stack<markOop, mtGC> _preserved_mark_stack; |
|
1 | 564 |
|
565 |
int* _hash_seed; |
|
566 |
||
567 |
// In support of multi-threaded concurrent phases |
|
568 |
YieldingFlexibleWorkGang* _conc_workers; |
|
569 |
||
570 |
// Performance Counters |
|
571 |
CollectorCounters* _gc_counters; |
|
572 |
||
573 |
// Initialization Errors |
|
574 |
bool _completed_initialization; |
|
575 |
||
576 |
// In support of ExplicitGCInvokesConcurrent |
|
18025 | 577 |
static bool _full_gc_requested; |
578 |
static GCCause::Cause _full_gc_cause; |
|
579 |
unsigned int _collection_count_start; |
|
341
6578aad59716
6634032: CMS: Need CMSInitiatingPermOccupancyFraction for perm, divorcing from CMSInitiatingOccupancyFraction
ysr
parents:
1
diff
changeset
|
580 |
|
1 | 581 |
// Should we unload classes this concurrent cycle? |
341
6578aad59716
6634032: CMS: Need CMSInitiatingPermOccupancyFraction for perm, divorcing from CMSInitiatingOccupancyFraction
ysr
parents:
1
diff
changeset
|
582 |
bool _should_unload_classes; |
6578aad59716
6634032: CMS: Need CMSInitiatingPermOccupancyFraction for perm, divorcing from CMSInitiatingOccupancyFraction
ysr
parents:
1
diff
changeset
|
583 |
unsigned int _concurrent_cycles_since_last_unload; |
6578aad59716
6634032: CMS: Need CMSInitiatingPermOccupancyFraction for perm, divorcing from CMSInitiatingOccupancyFraction
ysr
parents:
1
diff
changeset
|
584 |
unsigned int concurrent_cycles_since_last_unload() const { |
6578aad59716
6634032: CMS: Need CMSInitiatingPermOccupancyFraction for perm, divorcing from CMSInitiatingOccupancyFraction
ysr
parents:
1
diff
changeset
|
585 |
return _concurrent_cycles_since_last_unload; |
6578aad59716
6634032: CMS: Need CMSInitiatingPermOccupancyFraction for perm, divorcing from CMSInitiatingOccupancyFraction
ysr
parents:
1
diff
changeset
|
586 |
} |
1 | 587 |
// Did we (allow) unload classes in the previous concurrent cycle? |
341
6578aad59716
6634032: CMS: Need CMSInitiatingPermOccupancyFraction for perm, divorcing from CMSInitiatingOccupancyFraction
ysr
parents:
1
diff
changeset
|
588 |
bool unloaded_classes_last_cycle() const { |
6578aad59716
6634032: CMS: Need CMSInitiatingPermOccupancyFraction for perm, divorcing from CMSInitiatingOccupancyFraction
ysr
parents:
1
diff
changeset
|
589 |
return concurrent_cycles_since_last_unload() == 0; |
1 | 590 |
} |
2885
7dd49b9daa4a
6848641: CMSCollector::_roots_scanning_options should be initialized
ysr
parents:
2105
diff
changeset
|
591 |
// Root scanning options for perm gen |
7dd49b9daa4a
6848641: CMSCollector::_roots_scanning_options should be initialized
ysr
parents:
2105
diff
changeset
|
592 |
int _roots_scanning_options; |
7dd49b9daa4a
6848641: CMSCollector::_roots_scanning_options should be initialized
ysr
parents:
2105
diff
changeset
|
593 |
int roots_scanning_options() const { return _roots_scanning_options; } |
7dd49b9daa4a
6848641: CMSCollector::_roots_scanning_options should be initialized
ysr
parents:
2105
diff
changeset
|
594 |
void add_root_scanning_option(int o) { _roots_scanning_options |= o; } |
7dd49b9daa4a
6848641: CMSCollector::_roots_scanning_options should be initialized
ysr
parents:
2105
diff
changeset
|
595 |
void remove_root_scanning_option(int o) { _roots_scanning_options &= ~o; } |
1 | 596 |
|
597 |
// Verification support |
|
598 |
CMSBitMap _verification_mark_bm; |
|
599 |
void verify_after_remark_work_1(); |
|
600 |
void verify_after_remark_work_2(); |
|
601 |
||
22551 | 602 |
// True if any verification flag is on. |
1 | 603 |
bool _verifying; |
604 |
bool verifying() const { return _verifying; } |
|
605 |
void set_verifying(bool v) { _verifying = v; } |
|
606 |
||
607 |
// Collector policy |
|
608 |
ConcurrentMarkSweepPolicy* _collector_policy; |
|
609 |
ConcurrentMarkSweepPolicy* collector_policy() { return _collector_policy; } |
|
610 |
||
17325
694922ea5785
8013184: CMS: Call reset_after_compaction() only if a compaction has been done
jmasa
parents:
17112
diff
changeset
|
611 |
void set_did_compact(bool v); |
694922ea5785
8013184: CMS: Call reset_after_compaction() only if a compaction has been done
jmasa
parents:
17112
diff
changeset
|
612 |
|
1 | 613 |
// XXX Move these to CMSStats ??? FIX ME !!! |
22551 | 614 |
elapsedTimer _inter_sweep_timer; // Time between sweeps |
615 |
elapsedTimer _intra_sweep_timer; // Time _in_ sweeps |
|
616 |
// Padded decaying average estimates of the above |
|
4574
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
3690
diff
changeset
|
617 |
AdaptivePaddedAverage _inter_sweep_estimate; |
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
3690
diff
changeset
|
618 |
AdaptivePaddedAverage _intra_sweep_estimate; |
1 | 619 |
|
18025 | 620 |
CMSTracer* _gc_tracer_cm; |
621 |
ConcurrentGCTimer* _gc_timer_cm; |
|
622 |
||
623 |
bool _cms_start_registered; |
|
624 |
||
625 |
GCHeapSummary _last_heap_summary; |
|
626 |
MetaspaceSummary _last_metaspace_summary; |
|
627 |
||
628 |
void register_foreground_gc_start(GCCause::Cause cause); |
|
629 |
void register_gc_start(GCCause::Cause cause); |
|
630 |
void register_gc_end(); |
|
631 |
void save_heap_summary(); |
|
632 |
void report_heap_summary(GCWhen::Type when); |
|
633 |
||
1 | 634 |
protected: |
22551 | 635 |
ConcurrentMarkSweepGeneration* _cmsGen; // Old gen (CMS) |
636 |
MemRegion _span; // Span covering above two |
|
637 |
CardTableRS* _ct; // Card table |
|
1 | 638 |
|
639 |
// CMS marking support structures |
|
640 |
CMSBitMap _markBitMap; |
|
641 |
CMSBitMap _modUnionTable; |
|
642 |
CMSMarkStack _markStack; |
|
643 |
||
22551 | 644 |
HeapWord* _restart_addr; // In support of marking stack overflow |
1 | 645 |
void lower_restart_addr(HeapWord* low); |
646 |
||
647 |
// Counters in support of marking stack / work queue overflow handling: |
|
648 |
// a non-zero value indicates certain types of overflow events during |
|
649 |
// the current CMS cycle and could lead to stack resizing efforts at |
|
650 |
// an opportune future time. |
|
651 |
size_t _ser_pmc_preclean_ovflw; |
|
652 |
size_t _ser_pmc_remark_ovflw; |
|
653 |
size_t _par_pmc_remark_ovflw; |
|
1605
6b43d186eb8d
6722113: CMS: Incorrect overflow handling during precleaning of Reference lists
ysr
parents:
1388
diff
changeset
|
654 |
size_t _ser_kac_preclean_ovflw; |
1 | 655 |
size_t _ser_kac_ovflw; |
656 |
size_t _par_kac_ovflw; |
|
1910 | 657 |
NOT_PRODUCT(ssize_t _num_par_pushes;) |
1 | 658 |
|
22551 | 659 |
// ("Weak") Reference processing support. |
1 | 660 |
ReferenceProcessor* _ref_processor; |
661 |
CMSIsAliveClosure _is_alive_closure; |
|
22551 | 662 |
// Keep this textually after _markBitMap and _span; c'tor dependency. |
1 | 663 |
|
22551 | 664 |
ConcurrentMarkSweepThread* _cmsThread; // The thread doing the work |
1 | 665 |
ModUnionClosure _modUnionClosure; |
666 |
ModUnionClosurePar _modUnionClosurePar; |
|
667 |
||
668 |
// CMS abstract state machine |
|
669 |
// initial_state: Idling |
|
670 |
// next_state(Idling) = {Marking} |
|
671 |
// next_state(Marking) = {Precleaning, Sweeping} |
|
672 |
// next_state(Precleaning) = {AbortablePreclean, FinalMarking} |
|
673 |
// next_state(AbortablePreclean) = {FinalMarking} |
|
674 |
// next_state(FinalMarking) = {Sweeping} |
|
675 |
// next_state(Sweeping) = {Resizing} |
|
676 |
// next_state(Resizing) = {Resetting} |
|
677 |
// next_state(Resetting) = {Idling} |
|
678 |
// The numeric values below are chosen so that: |
|
679 |
// . _collectorState <= Idling == post-sweep && pre-mark |
|
680 |
// . _collectorState in (Idling, Sweeping) == {initial,final}marking || |
|
681 |
// precleaning || abortablePrecleanb |
|
4574
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
3690
diff
changeset
|
682 |
public: |
1 | 683 |
enum CollectorState { |
684 |
Resizing = 0, |
|
685 |
Resetting = 1, |
|
686 |
Idling = 2, |
|
687 |
InitialMarking = 3, |
|
688 |
Marking = 4, |
|
689 |
Precleaning = 5, |
|
690 |
AbortablePreclean = 6, |
|
691 |
FinalMarking = 7, |
|
692 |
Sweeping = 8 |
|
693 |
}; |
|
4574
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
3690
diff
changeset
|
694 |
protected: |
1 | 695 |
static CollectorState _collectorState; |
696 |
||
697 |
// State related to prologue/epilogue invocation for my generations |
|
698 |
bool _between_prologue_and_epilogue; |
|
699 |
||
22551 | 700 |
// Signaling/State related to coordination between fore- and background GC |
1 | 701 |
// Note: When the baton has been passed from background GC to foreground GC, |
702 |
// _foregroundGCIsActive is true and _foregroundGCShouldWait is false. |
|
703 |
static bool _foregroundGCIsActive; // true iff foreground collector is active or |
|
704 |
// wants to go active |
|
705 |
static bool _foregroundGCShouldWait; // true iff background GC is active and has not |
|
706 |
// yet passed the baton to the foreground GC |
|
707 |
||
708 |
// Support for CMSScheduleRemark (abortable preclean) |
|
709 |
bool _abort_preclean; |
|
710 |
bool _start_sampling; |
|
711 |
||
712 |
int _numYields; |
|
713 |
size_t _numDirtyCards; |
|
4574
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
3690
diff
changeset
|
714 |
size_t _sweep_count; |
22551 | 715 |
// Number of full gc's since the last concurrent gc. |
1 | 716 |
uint _full_gcs_since_conc_gc; |
717 |
||
22551 | 718 |
// Occupancy used for bootstrapping stats |
1 | 719 |
double _bootstrap_occupancy; |
720 |
||
22551 | 721 |
// Timer |
1 | 722 |
elapsedTimer _timer; |
723 |
||
724 |
// Timing, allocation and promotion statistics, used for scheduling. |
|
725 |
CMSStats _stats; |
|
726 |
||
727 |
// Allocation limits installed in the young gen, used only in |
|
728 |
// CMSIncrementalMode. When an allocation in the young gen would cross one of |
|
729 |
// these limits, the cms generation is notified and the cms thread is started |
|
730 |
// or stopped, respectively. |
|
731 |
HeapWord* _icms_start_limit; |
|
732 |
HeapWord* _icms_stop_limit; |
|
733 |
||
734 |
enum CMS_op_type { |
|
735 |
CMS_op_checkpointRootsInitial, |
|
736 |
CMS_op_checkpointRootsFinal |
|
737 |
}; |
|
738 |
||
12630
ddf6ee008138
7166894: Add gc cause to GC logging for all collectors
brutisso
parents:
12507
diff
changeset
|
739 |
void do_CMS_operation(CMS_op_type op, GCCause::Cause gc_cause); |
1 | 740 |
bool stop_world_and_do(CMS_op_type op); |
741 |
||
742 |
OopTaskQueueSet* task_queues() { return _task_queues; } |
|
743 |
int* hash_seed(int i) { return &_hash_seed[i]; } |
|
744 |
YieldingFlexibleWorkGang* conc_workers() { return _conc_workers; } |
|
745 |
||
746 |
// Support for parallelizing Eden rescan in CMS remark phase |
|
747 |
void sample_eden(); // ... sample Eden space top |
|
748 |
||
749 |
private: |
|
750 |
// Support for parallelizing young gen rescan in CMS remark phase |
|
751 |
Generation* _young_gen; // the younger gen |
|
752 |
HeapWord** _top_addr; // ... Top of Eden |
|
753 |
HeapWord** _end_addr; // ... End of Eden |
|
18994
d32a17b7502c
6990419: CMS Remaining work for 6572569: consistently skewed work distribution in (long) re-mark pauses
jmasa
parents:
18687
diff
changeset
|
754 |
Mutex* _eden_chunk_lock; |
1 | 755 |
HeapWord** _eden_chunk_array; // ... Eden partitioning array |
756 |
size_t _eden_chunk_index; // ... top (exclusive) of array |
|
757 |
size_t _eden_chunk_capacity; // ... max entries in array |
|
758 |
||
759 |
// Support for parallelizing survivor space rescan |
|
760 |
HeapWord** _survivor_chunk_array; |
|
761 |
size_t _survivor_chunk_index; |
|
762 |
size_t _survivor_chunk_capacity; |
|
763 |
size_t* _cursor; |
|
764 |
ChunkArray* _survivor_plab_array; |
|
765 |
||
766 |
// Support for marking stack overflow handling |
|
767 |
bool take_from_overflow_list(size_t num, CMSMarkStack* to_stack); |
|
6759
67b1a69ef5aa
6984287: Regularize how GC parallel workers are specified.
jmasa
parents:
6423
diff
changeset
|
768 |
bool par_take_from_overflow_list(size_t num, |
67b1a69ef5aa
6984287: Regularize how GC parallel workers are specified.
jmasa
parents:
6423
diff
changeset
|
769 |
OopTaskQueue* to_work_q, |
67b1a69ef5aa
6984287: Regularize how GC parallel workers are specified.
jmasa
parents:
6423
diff
changeset
|
770 |
int no_of_gc_threads); |
1 | 771 |
void push_on_overflow_list(oop p); |
772 |
void par_push_on_overflow_list(oop p); |
|
22551 | 773 |
// The following is, obviously, not, in general, "MT-stable" |
1 | 774 |
bool overflow_list_is_empty() const; |
775 |
||
776 |
void preserve_mark_if_necessary(oop p); |
|
777 |
void par_preserve_mark_if_necessary(oop p); |
|
778 |
void preserve_mark_work(oop p, markOop m); |
|
779 |
void restore_preserved_marks_if_any(); |
|
780 |
NOT_PRODUCT(bool no_preserved_marks() const;) |
|
22551 | 781 |
// In support of testing overflow code |
1 | 782 |
NOT_PRODUCT(int _overflow_counter;) |
22551 | 783 |
NOT_PRODUCT(bool simulate_overflow();) // Sequential |
1 | 784 |
NOT_PRODUCT(bool par_simulate_overflow();) // MT version |
785 |
||
786 |
// CMS work methods |
|
22551 | 787 |
void checkpointRootsInitialWork(bool asynch); // Initial checkpoint work |
1 | 788 |
|
22551 | 789 |
// A return value of false indicates failure due to stack overflow |
790 |
bool markFromRootsWork(bool asynch); // Concurrent marking work |
|
1 | 791 |
|
792 |
public: // FIX ME!!! only for testing |
|
22551 | 793 |
bool do_marking_st(bool asynch); // Single-threaded marking |
794 |
bool do_marking_mt(bool asynch); // Multi-threaded marking |
|
1 | 795 |
|
796 |
private: |
|
797 |
||
22551 | 798 |
// Concurrent precleaning work |
1 | 799 |
size_t preclean_mod_union_table(ConcurrentMarkSweepGeneration* gen, |
800 |
ScanMarkedObjectsAgainCarefullyClosure* cl); |
|
801 |
size_t preclean_card_table(ConcurrentMarkSweepGeneration* gen, |
|
802 |
ScanMarkedObjectsAgainCarefullyClosure* cl); |
|
803 |
// Does precleaning work, returning a quantity indicative of |
|
804 |
// the amount of "useful work" done. |
|
805 |
size_t preclean_work(bool clean_refs, bool clean_survivors); |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
806 |
void preclean_klasses(MarkRefsIntoAndScanClosure* cl, Mutex* freelistLock); |
1 | 807 |
void abortable_preclean(); // Preclean while looking for possible abort |
808 |
void initialize_sequential_subtasks_for_young_gen_rescan(int i); |
|
809 |
// Helper function for above; merge-sorts the per-thread plab samples |
|
6759
67b1a69ef5aa
6984287: Regularize how GC parallel workers are specified.
jmasa
parents:
6423
diff
changeset
|
810 |
void merge_survivor_plab_arrays(ContiguousSpace* surv, int no_of_gc_threads); |
1 | 811 |
// Resets (i.e. clears) the per-thread plab sample vectors |
812 |
void reset_survivor_plab_arrays(); |
|
813 |
||
22551 | 814 |
// Final (second) checkpoint work |
1 | 815 |
void checkpointRootsFinalWork(bool asynch, bool clear_all_soft_refs, |
816 |
bool init_mark_was_synchronous); |
|
22551 | 817 |
// Work routine for parallel version of remark |
1 | 818 |
void do_remark_parallel(); |
22551 | 819 |
// Work routine for non-parallel version of remark |
1 | 820 |
void do_remark_non_parallel(); |
22551 | 821 |
// Reference processing work routine (during second checkpoint) |
1 | 822 |
void refProcessingWork(bool asynch, bool clear_all_soft_refs); |
823 |
||
22551 | 824 |
// Concurrent sweeping work |
1 | 825 |
void sweepWork(ConcurrentMarkSweepGeneration* gen, bool asynch); |
826 |
||
22551 | 827 |
// (Concurrent) resetting of support data structures |
1 | 828 |
void reset(bool asynch); |
829 |
||
830 |
// Clear _expansion_cause fields of constituent generations |
|
831 |
void clear_expansion_cause(); |
|
832 |
||
22551 | 833 |
// An auxiliary method used to record the ends of |
1 | 834 |
// used regions of each generation to limit the extent of sweep |
835 |
void save_sweep_limits(); |
|
836 |
||
837 |
// A work method used by foreground collection to determine |
|
838 |
// what type of collection (compacting or not, continuing or fresh) |
|
839 |
// it should do. |
|
840 |
void decide_foreground_collection_type(bool clear_all_soft_refs, |
|
841 |
bool* should_compact, bool* should_start_over); |
|
842 |
||
843 |
// A work method used by the foreground collector to do |
|
844 |
// a mark-sweep-compact. |
|
845 |
void do_compaction_work(bool clear_all_soft_refs); |
|
846 |
||
847 |
// A work method used by the foreground collector to do |
|
848 |
// a mark-sweep, after taking over from a possibly on-going |
|
849 |
// concurrent mark-sweep collection. |
|
850 |
void do_mark_sweep_work(bool clear_all_soft_refs, |
|
851 |
CollectorState first_state, bool should_start_over); |
|
852 |
||
18025 | 853 |
// Work methods for reporting concurrent mode interruption or failure |
854 |
bool is_external_interruption(); |
|
855 |
void report_concurrent_mode_interruption(); |
|
856 |
||
22551 | 857 |
// If the background GC is active, acquire control from the background |
1 | 858 |
// GC and do the collection. |
859 |
void acquire_control_and_collect(bool full, bool clear_all_soft_refs); |
|
860 |
||
861 |
// For synchronizing passing of control from background to foreground |
|
862 |
// GC. waitForForegroundGC() is called by the background |
|
863 |
// collector. It if had to wait for a foreground collection, |
|
864 |
// it returns true and the background collection should assume |
|
865 |
// that the collection was finished by the foreground |
|
866 |
// collector. |
|
867 |
bool waitForForegroundGC(); |
|
868 |
||
869 |
// Incremental mode triggering: recompute the icms duty cycle and set the |
|
870 |
// allocation limits in the young gen. |
|
871 |
void icms_update_allocation_limits(); |
|
872 |
||
873 |
size_t block_size_using_printezis_bits(HeapWord* addr) const; |
|
874 |
size_t block_size_if_printezis_bits(HeapWord* addr) const; |
|
875 |
HeapWord* next_card_start_after_block(HeapWord* addr) const; |
|
876 |
||
877 |
void setup_cms_unloading_and_verification_state(); |
|
878 |
public: |
|
879 |
CMSCollector(ConcurrentMarkSweepGeneration* cmsGen, |
|
880 |
CardTableRS* ct, |
|
881 |
ConcurrentMarkSweepPolicy* cp); |
|
882 |
ConcurrentMarkSweepThread* cmsThread() { return _cmsThread; } |
|
883 |
||
884 |
ReferenceProcessor* ref_processor() { return _ref_processor; } |
|
885 |
void ref_processor_init(); |
|
886 |
||
887 |
Mutex* bitMapLock() const { return _markBitMap.lock(); } |
|
888 |
static CollectorState abstract_state() { return _collectorState; } |
|
889 |
||
890 |
bool should_abort_preclean() const; // Whether preclean should be aborted. |
|
891 |
size_t get_eden_used() const; |
|
892 |
size_t get_eden_capacity() const; |
|
893 |
||
894 |
ConcurrentMarkSweepGeneration* cmsGen() { return _cmsGen; } |
|
895 |
||
22551 | 896 |
// Locking checks |
1 | 897 |
NOT_PRODUCT(static bool have_cms_token();) |
898 |
||
899 |
// XXXPERM bool should_collect(bool full, size_t size, bool tlab); |
|
900 |
bool shouldConcurrentCollect(); |
|
901 |
||
902 |
void collect(bool full, |
|
903 |
bool clear_all_soft_refs, |
|
904 |
size_t size, |
|
905 |
bool tlab); |
|
18025 | 906 |
void collect_in_background(bool clear_all_soft_refs, GCCause::Cause cause); |
907 |
void collect_in_foreground(bool clear_all_soft_refs, GCCause::Cause cause); |
|
1 | 908 |
|
909 |
// In support of ExplicitGCInvokesConcurrent |
|
18025 | 910 |
static void request_full_gc(unsigned int full_gc_count, GCCause::Cause cause); |
1 | 911 |
// Should we unload classes in a particular concurrent cycle? |
341
6578aad59716
6634032: CMS: Need CMSInitiatingPermOccupancyFraction for perm, divorcing from CMSInitiatingOccupancyFraction
ysr
parents:
1
diff
changeset
|
912 |
bool should_unload_classes() const { |
6578aad59716
6634032: CMS: Need CMSInitiatingPermOccupancyFraction for perm, divorcing from CMSInitiatingOccupancyFraction
ysr
parents:
1
diff
changeset
|
913 |
return _should_unload_classes; |
1 | 914 |
} |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
915 |
void update_should_unload_classes(); |
1 | 916 |
|
917 |
void direct_allocated(HeapWord* start, size_t size); |
|
918 |
||
919 |
// Object is dead if not marked and current phase is sweeping. |
|
920 |
bool is_dead_obj(oop obj) const; |
|
921 |
||
922 |
// After a promotion (of "start"), do any necessary marking. |
|
923 |
// If "par", then it's being done by a parallel GC thread. |
|
924 |
// The last two args indicate if we need precise marking |
|
925 |
// and if so the size of the object so it can be dirtied |
|
926 |
// in its entirety. |
|
927 |
void promoted(bool par, HeapWord* start, |
|
928 |
bool is_obj_array, size_t obj_size); |
|
929 |
||
930 |
HeapWord* allocation_limit_reached(Space* space, HeapWord* top, |
|
931 |
size_t word_size); |
|
932 |
||
933 |
void getFreelistLocks() const; |
|
934 |
void releaseFreelistLocks() const; |
|
935 |
bool haveFreelistLocks() const; |
|
936 |
||
16681
d64161ca3e3c
8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents:
15605
diff
changeset
|
937 |
// Adjust size of underlying generation |
d64161ca3e3c
8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents:
15605
diff
changeset
|
938 |
void compute_new_size(); |
d64161ca3e3c
8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents:
15605
diff
changeset
|
939 |
|
1 | 940 |
// GC prologue and epilogue |
941 |
void gc_prologue(bool full); |
|
942 |
void gc_epilogue(bool full); |
|
943 |
||
944 |
jlong time_of_last_gc(jlong now) { |
|
945 |
if (_collectorState <= Idling) { |
|
946 |
// gc not in progress |
|
947 |
return _time_of_last_gc; |
|
948 |
} else { |
|
949 |
// collection in progress |
|
950 |
return now; |
|
951 |
} |
|
952 |
} |
|
953 |
||
954 |
// Support for parallel remark of survivor space |
|
955 |
void* get_data_recorder(int thr_num); |
|
18994
d32a17b7502c
6990419: CMS Remaining work for 6572569: consistently skewed work distribution in (long) re-mark pauses
jmasa
parents:
18687
diff
changeset
|
956 |
void sample_eden_chunk(); |
1 | 957 |
|
958 |
CMSBitMap* markBitMap() { return &_markBitMap; } |
|
959 |
void directAllocated(HeapWord* start, size_t size); |
|
960 |
||
22551 | 961 |
// Main CMS steps and related support |
1 | 962 |
void checkpointRootsInitial(bool asynch); |
963 |
bool markFromRoots(bool asynch); // a return value of false indicates failure |
|
964 |
// due to stack overflow |
|
965 |
void preclean(); |
|
966 |
void checkpointRootsFinal(bool asynch, bool clear_all_soft_refs, |
|
967 |
bool init_mark_was_synchronous); |
|
968 |
void sweep(bool asynch); |
|
969 |
||
970 |
// Check that the currently executing thread is the expected |
|
971 |
// one (foreground collector or background collector). |
|
4574
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
3690
diff
changeset
|
972 |
static void check_correct_thread_executing() PRODUCT_RETURN; |
1 | 973 |
// XXXPERM void print_statistics() PRODUCT_RETURN; |
974 |
||
975 |
bool is_cms_reachable(HeapWord* addr); |
|
976 |
||
977 |
// Performance Counter Support |
|
978 |
CollectorCounters* counters() { return _gc_counters; } |
|
979 |
||
22551 | 980 |
// Timer stuff |
1 | 981 |
void startTimer() { assert(!_timer.is_active(), "Error"); _timer.start(); } |
982 |
void stopTimer() { assert( _timer.is_active(), "Error"); _timer.stop(); } |
|
983 |
void resetTimer() { assert(!_timer.is_active(), "Error"); _timer.reset(); } |
|
984 |
double timerValue() { assert(!_timer.is_active(), "Error"); return _timer.seconds(); } |
|
985 |
||
986 |
int yields() { return _numYields; } |
|
987 |
void resetYields() { _numYields = 0; } |
|
988 |
void incrementYields() { _numYields++; } |
|
989 |
void resetNumDirtyCards() { _numDirtyCards = 0; } |
|
990 |
void incrementNumDirtyCards(size_t num) { _numDirtyCards += num; } |
|
991 |
size_t numDirtyCards() { return _numDirtyCards; } |
|
992 |
||
993 |
static bool foregroundGCShouldWait() { return _foregroundGCShouldWait; } |
|
994 |
static void set_foregroundGCShouldWait(bool v) { _foregroundGCShouldWait = v; } |
|
995 |
static bool foregroundGCIsActive() { return _foregroundGCIsActive; } |
|
996 |
static void set_foregroundGCIsActive(bool v) { _foregroundGCIsActive = v; } |
|
4574
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
3690
diff
changeset
|
997 |
size_t sweep_count() const { return _sweep_count; } |
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
3690
diff
changeset
|
998 |
void increment_sweep_count() { _sweep_count++; } |
1 | 999 |
|
1000 |
// Timers/stats for gc scheduling and incremental mode pacing. |
|
1001 |
CMSStats& stats() { return _stats; } |
|
1002 |
||
1003 |
// Convenience methods that check whether CMSIncrementalMode is enabled and |
|
1004 |
// forward to the corresponding methods in ConcurrentMarkSweepThread. |
|
1005 |
static void start_icms(); |
|
1006 |
static void stop_icms(); // Called at the end of the cms cycle. |
|
1007 |
static void disable_icms(); // Called before a foreground collection. |
|
1008 |
static void enable_icms(); // Called after a foreground collection. |
|
1009 |
void icms_wait(); // Called at yield points. |
|
1010 |
||
1011 |
// Adaptive size policy |
|
1012 |
CMSAdaptiveSizePolicy* size_policy(); |
|
1013 |
CMSGCAdaptivePolicyCounters* gc_adaptive_policy_counters(); |
|
1014 |
||
16685
41c34debcde0
8011872: Include Bit Map addresses in the hs_err files
stefank
parents:
16681
diff
changeset
|
1015 |
static void print_on_error(outputStream* st); |
41c34debcde0
8011872: Include Bit Map addresses in the hs_err files
stefank
parents:
16681
diff
changeset
|
1016 |
|
22551 | 1017 |
// Debugging |
12379 | 1018 |
void verify(); |
17112
e49af4ba7755
8013132: Add a flag to turn off the output of the verbose verification code
stefank
parents:
16685
diff
changeset
|
1019 |
bool verify_after_remark(bool silent = VerifySilently); |
1 | 1020 |
void verify_ok_to_terminate() const PRODUCT_RETURN; |
1021 |
void verify_work_stacks_empty() const PRODUCT_RETURN; |
|
1022 |
void verify_overflow_empty() const PRODUCT_RETURN; |
|
1023 |
||
22551 | 1024 |
// Convenience methods in support of debugging |
1 | 1025 |
static const size_t skip_header_HeapWords() PRODUCT_RETURN0; |
1026 |
HeapWord* block_start(const void* p) const PRODUCT_RETURN0; |
|
1027 |
||
22551 | 1028 |
// Accessors |
1 | 1029 |
CMSMarkStack* verification_mark_stack() { return &_markStack; } |
1030 |
CMSBitMap* verification_mark_bm() { return &_verification_mark_bm; } |
|
1031 |
||
1032 |
// Initialization errors |
|
1033 |
bool completed_initialization() { return _completed_initialization; } |
|
18994
d32a17b7502c
6990419: CMS Remaining work for 6572569: consistently skewed work distribution in (long) re-mark pauses
jmasa
parents:
18687
diff
changeset
|
1034 |
|
d32a17b7502c
6990419: CMS Remaining work for 6572569: consistently skewed work distribution in (long) re-mark pauses
jmasa
parents:
18687
diff
changeset
|
1035 |
void print_eden_and_survivor_chunk_arrays(); |
1 | 1036 |
}; |
1037 |
||
1038 |
class CMSExpansionCause : public AllStatic { |
|
1039 |
public: |
|
1040 |
enum Cause { |
|
1041 |
_no_expansion, |
|
1042 |
_satisfy_free_ratio, |
|
1043 |
_satisfy_promotion, |
|
1044 |
_satisfy_allocation, |
|
1045 |
_allocate_par_lab, |
|
1046 |
_allocate_par_spooling_space, |
|
1047 |
_adaptive_size_policy |
|
1048 |
}; |
|
1049 |
// Return a string describing the cause of the expansion. |
|
1050 |
static const char* to_string(CMSExpansionCause::Cause cause); |
|
1051 |
}; |
|
1052 |
||
1053 |
class ConcurrentMarkSweepGeneration: public CardGeneration { |
|
1054 |
friend class VMStructs; |
|
1055 |
friend class ConcurrentMarkSweepThread; |
|
1056 |
friend class ConcurrentMarkSweep; |
|
1057 |
friend class CMSCollector; |
|
1058 |
protected: |
|
1059 |
static CMSCollector* _collector; // the collector that collects us |
|
1060 |
CompactibleFreeListSpace* _cmsSpace; // underlying space (only one for now) |
|
1061 |
||
1062 |
// Performance Counters |
|
1063 |
GenerationCounters* _gen_counters; |
|
1064 |
GSpaceCounters* _space_counters; |
|
1065 |
||
1066 |
// Words directly allocated, used by CMSStats. |
|
1067 |
size_t _direct_allocated_words; |
|
1068 |
||
1069 |
// Non-product stat counters |
|
1070 |
NOT_PRODUCT( |
|
6258
68f252c6e825
6948538: CMS: BOT walkers can fall into object allocation and initialization cracks
ysr
parents:
6245
diff
changeset
|
1071 |
size_t _numObjectsPromoted; |
68f252c6e825
6948538: CMS: BOT walkers can fall into object allocation and initialization cracks
ysr
parents:
6245
diff
changeset
|
1072 |
size_t _numWordsPromoted; |
68f252c6e825
6948538: CMS: BOT walkers can fall into object allocation and initialization cracks
ysr
parents:
6245
diff
changeset
|
1073 |
size_t _numObjectsAllocated; |
68f252c6e825
6948538: CMS: BOT walkers can fall into object allocation and initialization cracks
ysr
parents:
6245
diff
changeset
|
1074 |
size_t _numWordsAllocated; |
1 | 1075 |
) |
1076 |
||
1077 |
// Used for sizing decisions |
|
1078 |
bool _incremental_collection_failed; |
|
1079 |
bool incremental_collection_failed() { |
|
1080 |
return _incremental_collection_failed; |
|
1081 |
} |
|
1082 |
void set_incremental_collection_failed() { |
|
1083 |
_incremental_collection_failed = true; |
|
1084 |
} |
|
1085 |
void clear_incremental_collection_failed() { |
|
1086 |
_incremental_collection_failed = false; |
|
1087 |
} |
|
1088 |
||
341
6578aad59716
6634032: CMS: Need CMSInitiatingPermOccupancyFraction for perm, divorcing from CMSInitiatingOccupancyFraction
ysr
parents:
1
diff
changeset
|
1089 |
// accessors |
6578aad59716
6634032: CMS: Need CMSInitiatingPermOccupancyFraction for perm, divorcing from CMSInitiatingOccupancyFraction
ysr
parents:
1
diff
changeset
|
1090 |
void set_expansion_cause(CMSExpansionCause::Cause v) { _expansion_cause = v;} |
6578aad59716
6634032: CMS: Need CMSInitiatingPermOccupancyFraction for perm, divorcing from CMSInitiatingOccupancyFraction
ysr
parents:
1
diff
changeset
|
1091 |
CMSExpansionCause::Cause expansion_cause() const { return _expansion_cause; } |
6578aad59716
6634032: CMS: Need CMSInitiatingPermOccupancyFraction for perm, divorcing from CMSInitiatingOccupancyFraction
ysr
parents:
1
diff
changeset
|
1092 |
|
1 | 1093 |
private: |
1094 |
// For parallel young-gen GC support. |
|
1095 |
CMSParGCThreadState** _par_gc_thread_states; |
|
1096 |
||
1097 |
// Reason generation was expanded |
|
1098 |
CMSExpansionCause::Cause _expansion_cause; |
|
1099 |
||
1100 |
// In support of MinChunkSize being larger than min object size |
|
1101 |
const double _dilatation_factor; |
|
1102 |
||
1103 |
enum CollectionTypes { |
|
1104 |
Concurrent_collection_type = 0, |
|
1105 |
MS_foreground_collection_type = 1, |
|
1106 |
MSC_foreground_collection_type = 2, |
|
1107 |
Unknown_collection_type = 3 |
|
1108 |
}; |
|
1109 |
||
1110 |
CollectionTypes _debug_collection_type; |
|
1111 |
||
22551 | 1112 |
// True if a compacting collection was done. |
17325
694922ea5785
8013184: CMS: Call reset_after_compaction() only if a compaction has been done
jmasa
parents:
17112
diff
changeset
|
1113 |
bool _did_compact; |
694922ea5785
8013184: CMS: Call reset_after_compaction() only if a compaction has been done
jmasa
parents:
17112
diff
changeset
|
1114 |
bool did_compact() { return _did_compact; } |
694922ea5785
8013184: CMS: Call reset_after_compaction() only if a compaction has been done
jmasa
parents:
17112
diff
changeset
|
1115 |
|
341
6578aad59716
6634032: CMS: Need CMSInitiatingPermOccupancyFraction for perm, divorcing from CMSInitiatingOccupancyFraction
ysr
parents:
1
diff
changeset
|
1116 |
// Fraction of current occupancy at which to start a CMS collection which |
6578aad59716
6634032: CMS: Need CMSInitiatingPermOccupancyFraction for perm, divorcing from CMSInitiatingOccupancyFraction
ysr
parents:
1
diff
changeset
|
1117 |
// will collect this generation (at least). |
6578aad59716
6634032: CMS: Need CMSInitiatingPermOccupancyFraction for perm, divorcing from CMSInitiatingOccupancyFraction
ysr
parents:
1
diff
changeset
|
1118 |
double _initiating_occupancy; |
6578aad59716
6634032: CMS: Need CMSInitiatingPermOccupancyFraction for perm, divorcing from CMSInitiatingOccupancyFraction
ysr
parents:
1
diff
changeset
|
1119 |
|
1 | 1120 |
protected: |
1121 |
// Shrink generation by specified size (returns false if unable to shrink) |
|
16681
d64161ca3e3c
8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents:
15605
diff
changeset
|
1122 |
void shrink_free_list_by(size_t bytes); |
1 | 1123 |
|
1124 |
// Update statistics for GC |
|
1125 |
virtual void update_gc_stats(int level, bool full); |
|
1126 |
||
1127 |
// Maximum available space in the generation (including uncommitted) |
|
1128 |
// space. |
|
1129 |
size_t max_available() const; |
|
1130 |
||
341
6578aad59716
6634032: CMS: Need CMSInitiatingPermOccupancyFraction for perm, divorcing from CMSInitiatingOccupancyFraction
ysr
parents:
1
diff
changeset
|
1131 |
// getter and initializer for _initiating_occupancy field. |
6578aad59716
6634032: CMS: Need CMSInitiatingPermOccupancyFraction for perm, divorcing from CMSInitiatingOccupancyFraction
ysr
parents:
1
diff
changeset
|
1132 |
double initiating_occupancy() const { return _initiating_occupancy; } |
15605 | 1133 |
void init_initiating_occupancy(intx io, uintx tr); |
341
6578aad59716
6634032: CMS: Need CMSInitiatingPermOccupancyFraction for perm, divorcing from CMSInitiatingOccupancyFraction
ysr
parents:
1
diff
changeset
|
1134 |
|
1 | 1135 |
public: |
1136 |
ConcurrentMarkSweepGeneration(ReservedSpace rs, size_t initial_byte_size, |
|
1137 |
int level, CardTableRS* ct, |
|
1138 |
bool use_adaptive_freelists, |
|
12507 | 1139 |
FreeBlockDictionary<FreeChunk>::DictionaryChoice); |
1 | 1140 |
|
1141 |
// Accessors |
|
1142 |
CMSCollector* collector() const { return _collector; } |
|
1143 |
static void set_collector(CMSCollector* collector) { |
|
1144 |
assert(_collector == NULL, "already set"); |
|
1145 |
_collector = collector; |
|
1146 |
} |
|
1147 |
CompactibleFreeListSpace* cmsSpace() const { return _cmsSpace; } |
|
1148 |
||
1149 |
Mutex* freelistLock() const; |
|
1150 |
||
1151 |
virtual Generation::Name kind() { return Generation::ConcurrentMarkSweep; } |
|
1152 |
||
1153 |
// Adaptive size policy |
|
1154 |
CMSAdaptiveSizePolicy* size_policy(); |
|
1155 |
||
17325
694922ea5785
8013184: CMS: Call reset_after_compaction() only if a compaction has been done
jmasa
parents:
17112
diff
changeset
|
1156 |
void set_did_compact(bool v) { _did_compact = v; } |
694922ea5785
8013184: CMS: Call reset_after_compaction() only if a compaction has been done
jmasa
parents:
17112
diff
changeset
|
1157 |
|
1 | 1158 |
bool refs_discovery_is_atomic() const { return false; } |
1159 |
bool refs_discovery_is_mt() const { |
|
1160 |
// Note: CMS does MT-discovery during the parallel-remark |
|
1161 |
// phases. Use ReferenceProcessorMTMutator to make refs |
|
1162 |
// discovery MT-safe during such phases or other parallel |
|
1163 |
// discovery phases in the future. This may all go away |
|
1164 |
// if/when we decide that refs discovery is sufficiently |
|
1165 |
// rare that the cost of the CAS's involved is in the |
|
1166 |
// noise. That's a measurement that should be done, and |
|
1167 |
// the code simplified if that turns out to be the case. |
|
8688
493d12ccc6db
6668573: CMS: reference processing crash if ParallelCMSThreads > ParallelGCThreads
ysr
parents:
7903
diff
changeset
|
1168 |
return ConcGCThreads > 1; |
1 | 1169 |
} |
1170 |
||
1171 |
// Override |
|
1172 |
virtual void ref_processor_init(); |
|
1173 |
||
979
c9479f1e0a94
6730514: assertion failure in mangling code when expanding by 0 bytes
jmasa
parents:
670
diff
changeset
|
1174 |
// Grow generation by specified size (returns false if unable to grow) |
c9479f1e0a94
6730514: assertion failure in mangling code when expanding by 0 bytes
jmasa
parents:
670
diff
changeset
|
1175 |
bool grow_by(size_t bytes); |
c9479f1e0a94
6730514: assertion failure in mangling code when expanding by 0 bytes
jmasa
parents:
670
diff
changeset
|
1176 |
// Grow generation to reserved size. |
c9479f1e0a94
6730514: assertion failure in mangling code when expanding by 0 bytes
jmasa
parents:
670
diff
changeset
|
1177 |
bool grow_to_reserved(); |
c9479f1e0a94
6730514: assertion failure in mangling code when expanding by 0 bytes
jmasa
parents:
670
diff
changeset
|
1178 |
|
1 | 1179 |
void clear_expansion_cause() { _expansion_cause = CMSExpansionCause::_no_expansion; } |
1180 |
||
1181 |
// Space enquiries |
|
1182 |
size_t capacity() const; |
|
1183 |
size_t used() const; |
|
1184 |
size_t free() const; |
|
341
6578aad59716
6634032: CMS: Need CMSInitiatingPermOccupancyFraction for perm, divorcing from CMSInitiatingOccupancyFraction
ysr
parents:
1
diff
changeset
|
1185 |
double occupancy() const { return ((double)used())/((double)capacity()); } |
1 | 1186 |
size_t contiguous_available() const; |
1187 |
size_t unsafe_max_alloc_nogc() const; |
|
1188 |
||
1189 |
// over-rides |
|
1190 |
MemRegion used_region() const; |
|
1191 |
MemRegion used_region_at_save_marks() const; |
|
1192 |
||
1193 |
// Does a "full" (forced) collection invoked on this generation collect |
|
1194 |
// all younger generations as well? Note that the second conjunct is a |
|
1195 |
// hack to allow the collection of the younger gen first if the flag is |
|
1196 |
// set. This is better than using th policy's should_collect_gen0_first() |
|
1197 |
// since that causes us to do an extra unnecessary pair of restart-&-stop-world. |
|
1198 |
virtual bool full_collects_younger_generations() const { |
|
1199 |
return UseCMSCompactAtFullCollection && !CollectGen0First; |
|
1200 |
} |
|
1201 |
||
1202 |
void space_iterate(SpaceClosure* blk, bool usedOnly = false); |
|
1203 |
||
1204 |
// Support for compaction |
|
1205 |
CompactibleSpace* first_compaction_space() const; |
|
22551 | 1206 |
// Adjust quantities in the generation affected by |
1 | 1207 |
// the compaction. |
1208 |
void reset_after_compaction(); |
|
1209 |
||
1210 |
// Allocation support |
|
1211 |
HeapWord* allocate(size_t size, bool tlab); |
|
1212 |
HeapWord* have_lock_and_allocate(size_t size, bool tlab); |
|
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
341
diff
changeset
|
1213 |
oop promote(oop obj, size_t obj_size); |
1 | 1214 |
HeapWord* par_allocate(size_t size, bool tlab) { |
1215 |
return allocate(size, tlab); |
|
1216 |
} |
|
1217 |
||
1218 |
// Incremental mode triggering. |
|
1219 |
HeapWord* allocation_limit_reached(Space* space, HeapWord* top, |
|
1220 |
size_t word_size); |
|
1221 |
||
1222 |
// Used by CMSStats to track direct allocation. The value is sampled and |
|
1223 |
// reset after each young gen collection. |
|
1224 |
size_t direct_allocated_words() const { return _direct_allocated_words; } |
|
1225 |
void reset_direct_allocated_words() { _direct_allocated_words = 0; } |
|
1226 |
||
1227 |
// Overrides for parallel promotion. |
|
1228 |
virtual oop par_promote(int thread_num, |
|
1229 |
oop obj, markOop m, size_t word_sz); |
|
1230 |
// This one should not be called for CMS. |
|
1231 |
virtual void par_promote_alloc_undo(int thread_num, |
|
1232 |
HeapWord* obj, size_t word_sz); |
|
1233 |
virtual void par_promote_alloc_done(int thread_num); |
|
1234 |
virtual void par_oop_since_save_marks_iterate_done(int thread_num); |
|
1235 |
||
6985
e9364ec299ac
6896603: CMS/GCH: collection_attempt_is_safe() ergo should use more recent data
ysr
parents:
6762
diff
changeset
|
1236 |
virtual bool promotion_attempt_is_safe(size_t promotion_in_bytes) const; |
1 | 1237 |
|
4574
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
3690
diff
changeset
|
1238 |
// Inform this (non-young) generation that a promotion failure was |
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
3690
diff
changeset
|
1239 |
// encountered during a collection of a younger generation that |
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
3690
diff
changeset
|
1240 |
// promotes into this generation. |
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
3690
diff
changeset
|
1241 |
virtual void promotion_failure_occurred(); |
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
3690
diff
changeset
|
1242 |
|
1 | 1243 |
bool should_collect(bool full, size_t size, bool tlab); |
341
6578aad59716
6634032: CMS: Need CMSInitiatingPermOccupancyFraction for perm, divorcing from CMSInitiatingOccupancyFraction
ysr
parents:
1
diff
changeset
|
1244 |
virtual bool should_concurrent_collect() const; |
6578aad59716
6634032: CMS: Need CMSInitiatingPermOccupancyFraction for perm, divorcing from CMSInitiatingOccupancyFraction
ysr
parents:
1
diff
changeset
|
1245 |
virtual bool is_too_full() const; |
1 | 1246 |
void collect(bool full, |
1247 |
bool clear_all_soft_refs, |
|
1248 |
size_t size, |
|
1249 |
bool tlab); |
|
1250 |
||
1251 |
HeapWord* expand_and_allocate(size_t word_size, |
|
1252 |
bool tlab, |
|
1253 |
bool parallel = false); |
|
1254 |
||
1255 |
// GC prologue and epilogue |
|
1256 |
void gc_prologue(bool full); |
|
1257 |
void gc_prologue_work(bool full, bool registerClosure, |
|
1258 |
ModUnionClosure* modUnionClosure); |
|
1259 |
void gc_epilogue(bool full); |
|
1260 |
void gc_epilogue_work(bool full); |
|
1261 |
||
1262 |
// Time since last GC of this generation |
|
1263 |
jlong time_of_last_gc(jlong now) { |
|
1264 |
return collector()->time_of_last_gc(now); |
|
1265 |
} |
|
1266 |
void update_time_of_last_gc(jlong now) { |
|
1267 |
collector()-> update_time_of_last_gc(now); |
|
1268 |
} |
|
1269 |
||
1270 |
// Allocation failure |
|
1271 |
void expand(size_t bytes, size_t expand_bytes, |
|
1272 |
CMSExpansionCause::Cause cause); |
|
979
c9479f1e0a94
6730514: assertion failure in mangling code when expanding by 0 bytes
jmasa
parents:
670
diff
changeset
|
1273 |
virtual bool expand(size_t bytes, size_t expand_bytes); |
1 | 1274 |
void shrink(size_t bytes); |
16681
d64161ca3e3c
8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents:
15605
diff
changeset
|
1275 |
void shrink_by(size_t bytes); |
1 | 1276 |
HeapWord* expand_and_par_lab_allocate(CMSParGCThreadState* ps, size_t word_sz); |
1277 |
bool expand_and_ensure_spooling_space(PromotionInfo* promo); |
|
1278 |
||
1279 |
// Iteration support and related enquiries |
|
1280 |
void save_marks(); |
|
1281 |
bool no_allocs_since_save_marks(); |
|
1282 |
void younger_refs_iterate(OopsInGenClosure* cl); |
|
1283 |
||
1284 |
// Iteration support specific to CMS generations |
|
1285 |
void save_sweep_limit(); |
|
1286 |
||
1287 |
// More iteration support |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
1288 |
virtual void oop_iterate(MemRegion mr, ExtendedOopClosure* cl); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
1289 |
virtual void oop_iterate(ExtendedOopClosure* cl); |
1893
c82e388e17c5
6689653: JMapPerm fails with UseConcMarkSweepIncGC and compressed oops off
jmasa
parents:
1605
diff
changeset
|
1290 |
virtual void safe_object_iterate(ObjectClosure* cl); |
1 | 1291 |
virtual void object_iterate(ObjectClosure* cl); |
1292 |
||
1293 |
// Need to declare the full complement of closures, whether we'll |
|
1294 |
// override them or not, or get message from the compiler: |
|
1295 |
// oop_since_save_marks_iterate_nv hides virtual function... |
|
1296 |
#define CMS_SINCE_SAVE_MARKS_DECL(OopClosureType, nv_suffix) \ |
|
1297 |
void oop_since_save_marks_iterate##nv_suffix(OopClosureType* cl); |
|
1298 |
ALL_SINCE_SAVE_MARKS_CLOSURES(CMS_SINCE_SAVE_MARKS_DECL) |
|
1299 |
||
1300 |
// Smart allocation XXX -- move to CFLSpace? |
|
1301 |
void setNearLargestChunk(); |
|
1302 |
bool isNearLargestChunk(HeapWord* addr); |
|
1303 |
||
22551 | 1304 |
// Get the chunk at the end of the space. Delegates to |
1 | 1305 |
// the space. |
1306 |
FreeChunk* find_chunk_at_end(); |
|
1307 |
||
1308 |
void post_compact(); |
|
1309 |
||
1310 |
// Debugging |
|
1311 |
void prepare_for_verify(); |
|
12379 | 1312 |
void verify(); |
1 | 1313 |
void print_statistics() PRODUCT_RETURN; |
1314 |
||
1315 |
// Performance Counters support |
|
1316 |
virtual void update_counters(); |
|
1317 |
virtual void update_counters(size_t used); |
|
1318 |
void initialize_performance_counters(); |
|
1319 |
CollectorCounters* counters() { return collector()->counters(); } |
|
1320 |
||
1321 |
// Support for parallel remark of survivor space |
|
1322 |
void* get_data_recorder(int thr_num) { |
|
1323 |
//Delegate to collector |
|
1324 |
return collector()->get_data_recorder(thr_num); |
|
1325 |
} |
|
18994
d32a17b7502c
6990419: CMS Remaining work for 6572569: consistently skewed work distribution in (long) re-mark pauses
jmasa
parents:
18687
diff
changeset
|
1326 |
void sample_eden_chunk() { |
d32a17b7502c
6990419: CMS Remaining work for 6572569: consistently skewed work distribution in (long) re-mark pauses
jmasa
parents:
18687
diff
changeset
|
1327 |
//Delegate to collector |
d32a17b7502c
6990419: CMS Remaining work for 6572569: consistently skewed work distribution in (long) re-mark pauses
jmasa
parents:
18687
diff
changeset
|
1328 |
return collector()->sample_eden_chunk(); |
d32a17b7502c
6990419: CMS Remaining work for 6572569: consistently skewed work distribution in (long) re-mark pauses
jmasa
parents:
18687
diff
changeset
|
1329 |
} |
1 | 1330 |
|
1331 |
// Printing |
|
1332 |
const char* name() const; |
|
1333 |
virtual const char* short_name() const { return "CMS"; } |
|
1334 |
void print() const; |
|
1335 |
void printOccupancy(const char* s); |
|
1336 |
bool must_be_youngest() const { return false; } |
|
1337 |
bool must_be_oldest() const { return true; } |
|
1338 |
||
16681
d64161ca3e3c
8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents:
15605
diff
changeset
|
1339 |
// Resize the generation after a compacting GC. The |
d64161ca3e3c
8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents:
15605
diff
changeset
|
1340 |
// generation can be treated as a contiguous space |
d64161ca3e3c
8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents:
15605
diff
changeset
|
1341 |
// after the compaction. |
d64161ca3e3c
8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents:
15605
diff
changeset
|
1342 |
virtual void compute_new_size(); |
d64161ca3e3c
8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents:
15605
diff
changeset
|
1343 |
// Resize the generation after a non-compacting |
d64161ca3e3c
8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents:
15605
diff
changeset
|
1344 |
// collection. |
d64161ca3e3c
8008508: CMS does not correctly reduce heap size after a Full GC
jmasa
parents:
15605
diff
changeset
|
1345 |
void compute_new_size_free_list(); |
1 | 1346 |
|
1347 |
CollectionTypes debug_collection_type() { return _debug_collection_type; } |
|
1348 |
void rotate_debug_collection_type(); |
|
1349 |
}; |
|
1350 |
||
1351 |
class ASConcurrentMarkSweepGeneration : public ConcurrentMarkSweepGeneration { |
|
1352 |
||
1353 |
// Return the size policy from the heap's collector |
|
1354 |
// policy casted to CMSAdaptiveSizePolicy*. |
|
1355 |
CMSAdaptiveSizePolicy* cms_size_policy() const; |
|
1356 |
||
1357 |
// Resize the generation based on the adaptive size |
|
1358 |
// policy. |
|
1359 |
void resize(size_t cur_promo, size_t desired_promo); |
|
1360 |
||
1361 |
// Return the GC counters from the collector policy |
|
1362 |
CMSGCAdaptivePolicyCounters* gc_adaptive_policy_counters(); |
|
1363 |
||
1364 |
virtual void shrink_by(size_t bytes); |
|
1365 |
||
1366 |
public: |
|
1367 |
ASConcurrentMarkSweepGeneration(ReservedSpace rs, size_t initial_byte_size, |
|
1368 |
int level, CardTableRS* ct, |
|
1369 |
bool use_adaptive_freelists, |
|
12507 | 1370 |
FreeBlockDictionary<FreeChunk>::DictionaryChoice |
1 | 1371 |
dictionaryChoice) : |
1372 |
ConcurrentMarkSweepGeneration(rs, initial_byte_size, level, ct, |
|
1373 |
use_adaptive_freelists, dictionaryChoice) {} |
|
1374 |
||
1375 |
virtual const char* short_name() const { return "ASCMS"; } |
|
1376 |
virtual Generation::Name kind() { return Generation::ASConcurrentMarkSweep; } |
|
1377 |
||
1378 |
virtual void update_counters(); |
|
1379 |
virtual void update_counters(size_t used); |
|
1380 |
}; |
|
1381 |
||
1382 |
// |
|
1383 |
// Closures of various sorts used by CMS to accomplish its work |
|
1384 |
// |
|
1385 |
||
1386 |
// This closure is used to do concurrent marking from the roots |
|
1387 |
// following the first checkpoint. |
|
1388 |
class MarkFromRootsClosure: public BitMapClosure { |
|
1389 |
CMSCollector* _collector; |
|
1390 |
MemRegion _span; |
|
1391 |
CMSBitMap* _bitMap; |
|
1392 |
CMSBitMap* _mut; |
|
1393 |
CMSMarkStack* _markStack; |
|
1394 |
bool _yield; |
|
1395 |
int _skipBits; |
|
1396 |
HeapWord* _finger; |
|
1397 |
HeapWord* _threshold; |
|
1398 |
DEBUG_ONLY(bool _verifying;) |
|
1399 |
||
1400 |
public: |
|
1401 |
MarkFromRootsClosure(CMSCollector* collector, MemRegion span, |
|
1402 |
CMSBitMap* bitMap, |
|
1403 |
CMSMarkStack* markStack, |
|
1404 |
bool should_yield, bool verifying = false); |
|
1374
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
390
diff
changeset
|
1405 |
bool do_bit(size_t offset); |
1 | 1406 |
void reset(HeapWord* addr); |
1407 |
inline void do_yield_check(); |
|
1408 |
||
1409 |
private: |
|
1410 |
void scanOopsInOop(HeapWord* ptr); |
|
1411 |
void do_yield_work(); |
|
1412 |
}; |
|
1413 |
||
1414 |
// This closure is used to do concurrent multi-threaded |
|
1415 |
// marking from the roots following the first checkpoint. |
|
1416 |
// XXX This should really be a subclass of The serial version |
|
1417 |
// above, but i have not had the time to refactor things cleanly. |
|
1418 |
class Par_MarkFromRootsClosure: public BitMapClosure { |
|
1419 |
CMSCollector* _collector; |
|
1420 |
MemRegion _whole_span; |
|
1421 |
MemRegion _span; |
|
1422 |
CMSBitMap* _bit_map; |
|
1423 |
CMSBitMap* _mut; |
|
1424 |
OopTaskQueue* _work_queue; |
|
1425 |
CMSMarkStack* _overflow_stack; |
|
1426 |
bool _yield; |
|
1427 |
int _skip_bits; |
|
1428 |
HeapWord* _finger; |
|
1429 |
HeapWord* _threshold; |
|
1430 |
CMSConcMarkingTask* _task; |
|
1431 |
public: |
|
1432 |
Par_MarkFromRootsClosure(CMSConcMarkingTask* task, CMSCollector* collector, |
|
1433 |
MemRegion span, |
|
1434 |
CMSBitMap* bit_map, |
|
1435 |
OopTaskQueue* work_queue, |
|
1436 |
CMSMarkStack* overflow_stack, |
|
1437 |
bool should_yield); |
|
1374
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
390
diff
changeset
|
1438 |
bool do_bit(size_t offset); |
1 | 1439 |
inline void do_yield_check(); |
1440 |
||
1441 |
private: |
|
1442 |
void scan_oops_in_oop(HeapWord* ptr); |
|
1443 |
void do_yield_work(); |
|
1444 |
bool get_work_from_overflow_stack(); |
|
1445 |
}; |
|
1446 |
||
1447 |
// The following closures are used to do certain kinds of verification of |
|
1448 |
// CMS marking. |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
1449 |
class PushAndMarkVerifyClosure: public CMSOopClosure { |
1 | 1450 |
CMSCollector* _collector; |
1451 |
MemRegion _span; |
|
1452 |
CMSBitMap* _verification_bm; |
|
1453 |
CMSBitMap* _cms_bm; |
|
1454 |
CMSMarkStack* _mark_stack; |
|
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
341
diff
changeset
|
1455 |
protected: |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
341
diff
changeset
|
1456 |
void do_oop(oop p); |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
341
diff
changeset
|
1457 |
template <class T> inline void do_oop_work(T *p) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
1458 |
oop obj = oopDesc::load_decode_heap_oop(p); |
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
341
diff
changeset
|
1459 |
do_oop(obj); |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
341
diff
changeset
|
1460 |
} |
1 | 1461 |
public: |
1462 |
PushAndMarkVerifyClosure(CMSCollector* cms_collector, |
|
1463 |
MemRegion span, |
|
1464 |
CMSBitMap* verification_bm, |
|
1465 |
CMSBitMap* cms_bm, |
|
1466 |
CMSMarkStack* mark_stack); |
|
1467 |
void do_oop(oop* p); |
|
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
341
diff
changeset
|
1468 |
void do_oop(narrowOop* p); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
1469 |
|
1 | 1470 |
// Deal with a stack overflow condition |
1471 |
void handle_stack_overflow(HeapWord* lost); |
|
1472 |
}; |
|
1473 |
||
1474 |
class MarkFromRootsVerifyClosure: public BitMapClosure { |
|
1475 |
CMSCollector* _collector; |
|
1476 |
MemRegion _span; |
|
1477 |
CMSBitMap* _verification_bm; |
|
1478 |
CMSBitMap* _cms_bm; |
|
1479 |
CMSMarkStack* _mark_stack; |
|
1480 |
HeapWord* _finger; |
|
1481 |
PushAndMarkVerifyClosure _pam_verify_closure; |
|
1482 |
public: |
|
1483 |
MarkFromRootsVerifyClosure(CMSCollector* collector, MemRegion span, |
|
1484 |
CMSBitMap* verification_bm, |
|
1485 |
CMSBitMap* cms_bm, |
|
1486 |
CMSMarkStack* mark_stack); |
|
1374
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
390
diff
changeset
|
1487 |
bool do_bit(size_t offset); |
1 | 1488 |
void reset(HeapWord* addr); |
1489 |
}; |
|
1490 |
||
1491 |
||
1492 |
// This closure is used to check that a certain set of bits is |
|
1493 |
// "empty" (i.e. the bit vector doesn't have any 1-bits). |
|
1494 |
class FalseBitMapClosure: public BitMapClosure { |
|
1495 |
public: |
|
1374
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
390
diff
changeset
|
1496 |
bool do_bit(size_t offset) { |
1 | 1497 |
guarantee(false, "Should not have a 1 bit"); |
1374
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
390
diff
changeset
|
1498 |
return true; |
1 | 1499 |
} |
1500 |
}; |
|
1501 |
||
1502 |
// This closure is used during the second checkpointing phase |
|
1503 |
// to rescan the marked objects on the dirty cards in the mod |
|
1504 |
// union table and the card table proper. It's invoked via |
|
1505 |
// MarkFromDirtyCardsClosure below. It uses either |
|
1506 |
// [Par_]MarkRefsIntoAndScanClosure (Par_ in the parallel case) |
|
1507 |
// declared in genOopClosures.hpp to accomplish some of its work. |
|
1508 |
// In the parallel case the bitMap is shared, so access to |
|
1509 |
// it needs to be suitably synchronized for updates by embedded |
|
1510 |
// closures that update it; however, this closure itself only |
|
1511 |
// reads the bit_map and because it is idempotent, is immune to |
|
1512 |
// reading stale values. |
|
1513 |
class ScanMarkedObjectsAgainClosure: public UpwardsObjectClosure { |
|
1514 |
#ifdef ASSERT |
|
1515 |
CMSCollector* _collector; |
|
1516 |
MemRegion _span; |
|
1517 |
union { |
|
1518 |
CMSMarkStack* _mark_stack; |
|
1519 |
OopTaskQueue* _work_queue; |
|
1520 |
}; |
|
1521 |
#endif // ASSERT |
|
1522 |
bool _parallel; |
|
1523 |
CMSBitMap* _bit_map; |
|
1524 |
union { |
|
1525 |
MarkRefsIntoAndScanClosure* _scan_closure; |
|
1526 |
Par_MarkRefsIntoAndScanClosure* _par_scan_closure; |
|
1527 |
}; |
|
1528 |
||
1529 |
public: |
|
1530 |
ScanMarkedObjectsAgainClosure(CMSCollector* collector, |
|
1531 |
MemRegion span, |
|
1532 |
ReferenceProcessor* rp, |
|
1533 |
CMSBitMap* bit_map, |
|
1534 |
CMSMarkStack* mark_stack, |
|
1535 |
MarkRefsIntoAndScanClosure* cl): |
|
1536 |
#ifdef ASSERT |
|
1537 |
_collector(collector), |
|
1538 |
_span(span), |
|
1539 |
_mark_stack(mark_stack), |
|
1540 |
#endif // ASSERT |
|
1541 |
_parallel(false), |
|
1542 |
_bit_map(bit_map), |
|
1543 |
_scan_closure(cl) { } |
|
1544 |
||
1545 |
ScanMarkedObjectsAgainClosure(CMSCollector* collector, |
|
1546 |
MemRegion span, |
|
1547 |
ReferenceProcessor* rp, |
|
1548 |
CMSBitMap* bit_map, |
|
1549 |
OopTaskQueue* work_queue, |
|
1550 |
Par_MarkRefsIntoAndScanClosure* cl): |
|
1551 |
#ifdef ASSERT |
|
1552 |
_collector(collector), |
|
1553 |
_span(span), |
|
1554 |
_work_queue(work_queue), |
|
1555 |
#endif // ASSERT |
|
1556 |
_parallel(true), |
|
1557 |
_bit_map(bit_map), |
|
1558 |
_par_scan_closure(cl) { } |
|
1559 |
||
1560 |
bool do_object_b(oop obj) { |
|
1561 |
guarantee(false, "Call do_object_b(oop, MemRegion) form instead"); |
|
1562 |
return false; |
|
1563 |
} |
|
1564 |
bool do_object_bm(oop p, MemRegion mr); |
|
1565 |
}; |
|
1566 |
||
1567 |
// This closure is used during the second checkpointing phase |
|
1568 |
// to rescan the marked objects on the dirty cards in the mod |
|
1569 |
// union table and the card table proper. It invokes |
|
1570 |
// ScanMarkedObjectsAgainClosure above to accomplish much of its work. |
|
1571 |
// In the parallel case, the bit map is shared and requires |
|
1572 |
// synchronized access. |
|
1573 |
class MarkFromDirtyCardsClosure: public MemRegionClosure { |
|
1574 |
CompactibleFreeListSpace* _space; |
|
1575 |
ScanMarkedObjectsAgainClosure _scan_cl; |
|
1576 |
size_t _num_dirty_cards; |
|
1577 |
||
1578 |
public: |
|
1579 |
MarkFromDirtyCardsClosure(CMSCollector* collector, |
|
1580 |
MemRegion span, |
|
1581 |
CompactibleFreeListSpace* space, |
|
1582 |
CMSBitMap* bit_map, |
|
1583 |
CMSMarkStack* mark_stack, |
|
1584 |
MarkRefsIntoAndScanClosure* cl): |
|
1585 |
_space(space), |
|
1586 |
_num_dirty_cards(0), |
|
1587 |
_scan_cl(collector, span, collector->ref_processor(), bit_map, |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
1588 |
mark_stack, cl) { } |
1 | 1589 |
|
1590 |
MarkFromDirtyCardsClosure(CMSCollector* collector, |
|
1591 |
MemRegion span, |
|
1592 |
CompactibleFreeListSpace* space, |
|
1593 |
CMSBitMap* bit_map, |
|
1594 |
OopTaskQueue* work_queue, |
|
1595 |
Par_MarkRefsIntoAndScanClosure* cl): |
|
1596 |
_space(space), |
|
1597 |
_num_dirty_cards(0), |
|
1598 |
_scan_cl(collector, span, collector->ref_processor(), bit_map, |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
1599 |
work_queue, cl) { } |
1 | 1600 |
|
1601 |
void do_MemRegion(MemRegion mr); |
|
1602 |
void set_space(CompactibleFreeListSpace* space) { _space = space; } |
|
1603 |
size_t num_dirty_cards() { return _num_dirty_cards; } |
|
1604 |
}; |
|
1605 |
||
1606 |
// This closure is used in the non-product build to check |
|
1607 |
// that there are no MemRegions with a certain property. |
|
1608 |
class FalseMemRegionClosure: public MemRegionClosure { |
|
1609 |
void do_MemRegion(MemRegion mr) { |
|
1610 |
guarantee(!mr.is_empty(), "Shouldn't be empty"); |
|
1611 |
guarantee(false, "Should never be here"); |
|
1612 |
} |
|
1613 |
}; |
|
1614 |
||
1615 |
// This closure is used during the precleaning phase |
|
1616 |
// to "carefully" rescan marked objects on dirty cards. |
|
1617 |
// It uses MarkRefsIntoAndScanClosure declared in genOopClosures.hpp |
|
1618 |
// to accomplish some of its work. |
|
1619 |
class ScanMarkedObjectsAgainCarefullyClosure: public ObjectClosureCareful { |
|
1620 |
CMSCollector* _collector; |
|
1621 |
MemRegion _span; |
|
1622 |
bool _yield; |
|
1623 |
Mutex* _freelistLock; |
|
1624 |
CMSBitMap* _bitMap; |
|
1625 |
CMSMarkStack* _markStack; |
|
1626 |
MarkRefsIntoAndScanClosure* _scanningClosure; |
|
1627 |
||
1628 |
public: |
|
1629 |
ScanMarkedObjectsAgainCarefullyClosure(CMSCollector* collector, |
|
1630 |
MemRegion span, |
|
1631 |
CMSBitMap* bitMap, |
|
1632 |
CMSMarkStack* markStack, |
|
1633 |
MarkRefsIntoAndScanClosure* cl, |
|
1634 |
bool should_yield): |
|
1635 |
_collector(collector), |
|
1636 |
_span(span), |
|
1637 |
_yield(should_yield), |
|
1638 |
_bitMap(bitMap), |
|
1639 |
_markStack(markStack), |
|
1640 |
_scanningClosure(cl) { |
|
1641 |
} |
|
1642 |
||
1643 |
void do_object(oop p) { |
|
1644 |
guarantee(false, "call do_object_careful instead"); |
|
1645 |
} |
|
1646 |
||
1647 |
size_t do_object_careful(oop p) { |
|
1648 |
guarantee(false, "Unexpected caller"); |
|
1649 |
return 0; |
|
1650 |
} |
|
1651 |
||
1652 |
size_t do_object_careful_m(oop p, MemRegion mr); |
|
1653 |
||
1654 |
void setFreelistLock(Mutex* m) { |
|
1655 |
_freelistLock = m; |
|
1656 |
_scanningClosure->set_freelistLock(m); |
|
1657 |
} |
|
1658 |
||
1659 |
private: |
|
1660 |
inline bool do_yield_check(); |
|
1661 |
||
1662 |
void do_yield_work(); |
|
1663 |
}; |
|
1664 |
||
1665 |
class SurvivorSpacePrecleanClosure: public ObjectClosureCareful { |
|
1666 |
CMSCollector* _collector; |
|
1667 |
MemRegion _span; |
|
1668 |
bool _yield; |
|
1669 |
CMSBitMap* _bit_map; |
|
1670 |
CMSMarkStack* _mark_stack; |
|
1671 |
PushAndMarkClosure* _scanning_closure; |
|
1672 |
unsigned int _before_count; |
|
1673 |
||
1674 |
public: |
|
1675 |
SurvivorSpacePrecleanClosure(CMSCollector* collector, |
|
1676 |
MemRegion span, |
|
1677 |
CMSBitMap* bit_map, |
|
1678 |
CMSMarkStack* mark_stack, |
|
1679 |
PushAndMarkClosure* cl, |
|
1680 |
unsigned int before_count, |
|
1681 |
bool should_yield): |
|
1682 |
_collector(collector), |
|
1683 |
_span(span), |
|
1684 |
_yield(should_yield), |
|
1685 |
_bit_map(bit_map), |
|
1686 |
_mark_stack(mark_stack), |
|
1687 |
_scanning_closure(cl), |
|
1688 |
_before_count(before_count) |
|
1689 |
{ } |
|
1690 |
||
1691 |
void do_object(oop p) { |
|
1692 |
guarantee(false, "call do_object_careful instead"); |
|
1693 |
} |
|
1694 |
||
1695 |
size_t do_object_careful(oop p); |
|
1696 |
||
1697 |
size_t do_object_careful_m(oop p, MemRegion mr) { |
|
1698 |
guarantee(false, "Unexpected caller"); |
|
1699 |
return 0; |
|
1700 |
} |
|
1701 |
||
1702 |
private: |
|
1703 |
inline void do_yield_check(); |
|
1704 |
void do_yield_work(); |
|
1705 |
}; |
|
1706 |
||
1707 |
// This closure is used to accomplish the sweeping work |
|
1708 |
// after the second checkpoint but before the concurrent reset |
|
1709 |
// phase. |
|
1710 |
// |
|
1711 |
// Terminology |
|
1712 |
// left hand chunk (LHC) - block of one or more chunks currently being |
|
1713 |
// coalesced. The LHC is available for coalescing with a new chunk. |
|
1714 |
// right hand chunk (RHC) - block that is currently being swept that is |
|
1715 |
// free or garbage that can be coalesced with the LHC. |
|
1716 |
// _inFreeRange is true if there is currently a LHC |
|
1717 |
// _lastFreeRangeCoalesced is true if the LHC consists of more than one chunk. |
|
1718 |
// _freeRangeInFreeLists is true if the LHC is in the free lists. |
|
1719 |
// _freeFinger is the address of the current LHC |
|
1720 |
class SweepClosure: public BlkClosureCareful { |
|
1721 |
CMSCollector* _collector; // collector doing the work |
|
1722 |
ConcurrentMarkSweepGeneration* _g; // Generation being swept |
|
1723 |
CompactibleFreeListSpace* _sp; // Space being swept |
|
9969
57932d7294a9
7042740: CMS: assert(n> q) failed: Looping at: ... blockOffsetTable.cpp:557
ysr
parents:
9623
diff
changeset
|
1724 |
HeapWord* _limit;// the address at or above which the sweep should stop |
57932d7294a9
7042740: CMS: assert(n> q) failed: Looping at: ... blockOffsetTable.cpp:557
ysr
parents:
9623
diff
changeset
|
1725 |
// because we do not expect newly garbage blocks |
57932d7294a9
7042740: CMS: assert(n> q) failed: Looping at: ... blockOffsetTable.cpp:557
ysr
parents:
9623
diff
changeset
|
1726 |
// eligible for sweeping past that address. |
1 | 1727 |
Mutex* _freelistLock; // Free list lock (in space) |
1728 |
CMSBitMap* _bitMap; // Marking bit map (in |
|
1729 |
// generation) |
|
1730 |
bool _inFreeRange; // Indicates if we are in the |
|
1731 |
// midst of a free run |
|
1732 |
bool _freeRangeInFreeLists; |
|
1733 |
// Often, we have just found |
|
1734 |
// a free chunk and started |
|
1735 |
// a new free range; we do not |
|
1736 |
// eagerly remove this chunk from |
|
1737 |
// the free lists unless there is |
|
1738 |
// a possibility of coalescing. |
|
1739 |
// When true, this flag indicates |
|
1740 |
// that the _freeFinger below |
|
1741 |
// points to a potentially free chunk |
|
1742 |
// that may still be in the free lists |
|
1743 |
bool _lastFreeRangeCoalesced; |
|
1744 |
// free range contains chunks |
|
1745 |
// coalesced |
|
1746 |
bool _yield; |
|
1747 |
// Whether sweeping should be |
|
1748 |
// done with yields. For instance |
|
1749 |
// when done by the foreground |
|
1750 |
// collector we shouldn't yield. |
|
1751 |
HeapWord* _freeFinger; // When _inFreeRange is set, the |
|
1752 |
// pointer to the "left hand |
|
1753 |
// chunk" |
|
1754 |
size_t _freeRangeSize; |
|
1755 |
// When _inFreeRange is set, this |
|
1756 |
// indicates the accumulated size |
|
1757 |
// of the "left hand chunk" |
|
1758 |
NOT_PRODUCT( |
|
1759 |
size_t _numObjectsFreed; |
|
1760 |
size_t _numWordsFreed; |
|
1761 |
size_t _numObjectsLive; |
|
1762 |
size_t _numWordsLive; |
|
1763 |
size_t _numObjectsAlreadyFree; |
|
1764 |
size_t _numWordsAlreadyFree; |
|
1765 |
FreeChunk* _last_fc; |
|
1766 |
) |
|
1767 |
private: |
|
1768 |
// Code that is common to a free chunk or garbage when |
|
1769 |
// encountered during sweeping. |
|
7903
c694e52ff9cb
7008136: CMS: assert((HeapWord*)nextChunk <= _limit) failed: sweep invariant
ysr
parents:
7397
diff
changeset
|
1770 |
void do_post_free_or_garbage_chunk(FreeChunk *fc, size_t chunkSize); |
1 | 1771 |
// Process a free chunk during sweeping. |
7903
c694e52ff9cb
7008136: CMS: assert((HeapWord*)nextChunk <= _limit) failed: sweep invariant
ysr
parents:
7397
diff
changeset
|
1772 |
void do_already_free_chunk(FreeChunk *fc); |
9969
57932d7294a9
7042740: CMS: assert(n> q) failed: Looping at: ... blockOffsetTable.cpp:557
ysr
parents:
9623
diff
changeset
|
1773 |
// Work method called when processing an already free or a |
57932d7294a9
7042740: CMS: assert(n> q) failed: Looping at: ... blockOffsetTable.cpp:557
ysr
parents:
9623
diff
changeset
|
1774 |
// freshly garbage chunk to do a lookahead and possibly a |
22551 | 1775 |
// preemptive flush if crossing over _limit. |
9969
57932d7294a9
7042740: CMS: assert(n> q) failed: Looping at: ... blockOffsetTable.cpp:557
ysr
parents:
9623
diff
changeset
|
1776 |
void lookahead_and_flush(FreeChunk* fc, size_t chunkSize); |
1 | 1777 |
// Process a garbage chunk during sweeping. |
7903
c694e52ff9cb
7008136: CMS: assert((HeapWord*)nextChunk <= _limit) failed: sweep invariant
ysr
parents:
7397
diff
changeset
|
1778 |
size_t do_garbage_chunk(FreeChunk *fc); |
1 | 1779 |
// Process a live chunk during sweeping. |
7903
c694e52ff9cb
7008136: CMS: assert((HeapWord*)nextChunk <= _limit) failed: sweep invariant
ysr
parents:
7397
diff
changeset
|
1780 |
size_t do_live_chunk(FreeChunk* fc); |
1 | 1781 |
|
1782 |
// Accessors. |
|
1783 |
HeapWord* freeFinger() const { return _freeFinger; } |
|
1784 |
void set_freeFinger(HeapWord* v) { _freeFinger = v; } |
|
1785 |
bool inFreeRange() const { return _inFreeRange; } |
|
1786 |
void set_inFreeRange(bool v) { _inFreeRange = v; } |
|
1787 |
bool lastFreeRangeCoalesced() const { return _lastFreeRangeCoalesced; } |
|
1788 |
void set_lastFreeRangeCoalesced(bool v) { _lastFreeRangeCoalesced = v; } |
|
1789 |
bool freeRangeInFreeLists() const { return _freeRangeInFreeLists; } |
|
1790 |
void set_freeRangeInFreeLists(bool v) { _freeRangeInFreeLists = v; } |
|
1791 |
||
1792 |
// Initialize a free range. |
|
1793 |
void initialize_free_range(HeapWord* freeFinger, bool freeRangeInFreeLists); |
|
1794 |
// Return this chunk to the free lists. |
|
7903
c694e52ff9cb
7008136: CMS: assert((HeapWord*)nextChunk <= _limit) failed: sweep invariant
ysr
parents:
7397
diff
changeset
|
1795 |
void flush_cur_free_chunk(HeapWord* chunk, size_t size); |
1 | 1796 |
|
1797 |
// Check if we should yield and do so when necessary. |
|
1798 |
inline void do_yield_check(HeapWord* addr); |
|
1799 |
||
1800 |
// Yield |
|
1801 |
void do_yield_work(HeapWord* addr); |
|
1802 |
||
1803 |
// Debugging/Printing |
|
9969
57932d7294a9
7042740: CMS: assert(n> q) failed: Looping at: ... blockOffsetTable.cpp:557
ysr
parents:
9623
diff
changeset
|
1804 |
void print_free_block_coalesced(FreeChunk* fc) const; |
1 | 1805 |
|
1806 |
public: |
|
1807 |
SweepClosure(CMSCollector* collector, ConcurrentMarkSweepGeneration* g, |
|
1808 |
CMSBitMap* bitMap, bool should_yield); |
|
9969
57932d7294a9
7042740: CMS: assert(n> q) failed: Looping at: ... blockOffsetTable.cpp:557
ysr
parents:
9623
diff
changeset
|
1809 |
~SweepClosure() PRODUCT_RETURN; |
1 | 1810 |
|
1811 |
size_t do_blk_careful(HeapWord* addr); |
|
9969
57932d7294a9
7042740: CMS: assert(n> q) failed: Looping at: ... blockOffsetTable.cpp:557
ysr
parents:
9623
diff
changeset
|
1812 |
void print() const { print_on(tty); } |
57932d7294a9
7042740: CMS: assert(n> q) failed: Looping at: ... blockOffsetTable.cpp:557
ysr
parents:
9623
diff
changeset
|
1813 |
void print_on(outputStream *st) const; |
1 | 1814 |
}; |
1815 |
||
1816 |
// Closures related to weak references processing |
|
1817 |
||
1818 |
// During CMS' weak reference processing, this is a |
|
1819 |
// work-routine/closure used to complete transitive |
|
1820 |
// marking of objects as live after a certain point |
|
1821 |
// in which an initial set has been completely accumulated. |
|
1605
6b43d186eb8d
6722113: CMS: Incorrect overflow handling during precleaning of Reference lists
ysr
parents:
1388
diff
changeset
|
1822 |
// This closure is currently used both during the final |
6b43d186eb8d
6722113: CMS: Incorrect overflow handling during precleaning of Reference lists
ysr
parents:
1388
diff
changeset
|
1823 |
// remark stop-world phase, as well as during the concurrent |
6b43d186eb8d
6722113: CMS: Incorrect overflow handling during precleaning of Reference lists
ysr
parents:
1388
diff
changeset
|
1824 |
// precleaning of the discovered reference lists. |
1 | 1825 |
class CMSDrainMarkingStackClosure: public VoidClosure { |
1826 |
CMSCollector* _collector; |
|
1827 |
MemRegion _span; |
|
1828 |
CMSMarkStack* _mark_stack; |
|
1829 |
CMSBitMap* _bit_map; |
|
1830 |
CMSKeepAliveClosure* _keep_alive; |
|
1605
6b43d186eb8d
6722113: CMS: Incorrect overflow handling during precleaning of Reference lists
ysr
parents:
1388
diff
changeset
|
1831 |
bool _concurrent_precleaning; |
1 | 1832 |
public: |
1833 |
CMSDrainMarkingStackClosure(CMSCollector* collector, MemRegion span, |
|
1834 |
CMSBitMap* bit_map, CMSMarkStack* mark_stack, |
|
1605
6b43d186eb8d
6722113: CMS: Incorrect overflow handling during precleaning of Reference lists
ysr
parents:
1388
diff
changeset
|
1835 |
CMSKeepAliveClosure* keep_alive, |
6b43d186eb8d
6722113: CMS: Incorrect overflow handling during precleaning of Reference lists
ysr
parents:
1388
diff
changeset
|
1836 |
bool cpc): |
1 | 1837 |
_collector(collector), |
1838 |
_span(span), |
|
1839 |
_bit_map(bit_map), |
|
1840 |
_mark_stack(mark_stack), |
|
1605
6b43d186eb8d
6722113: CMS: Incorrect overflow handling during precleaning of Reference lists
ysr
parents:
1388
diff
changeset
|
1841 |
_keep_alive(keep_alive), |
6b43d186eb8d
6722113: CMS: Incorrect overflow handling during precleaning of Reference lists
ysr
parents:
1388
diff
changeset
|
1842 |
_concurrent_precleaning(cpc) { |
6b43d186eb8d
6722113: CMS: Incorrect overflow handling during precleaning of Reference lists
ysr
parents:
1388
diff
changeset
|
1843 |
assert(_concurrent_precleaning == _keep_alive->concurrent_precleaning(), |
6b43d186eb8d
6722113: CMS: Incorrect overflow handling during precleaning of Reference lists
ysr
parents:
1388
diff
changeset
|
1844 |
"Mismatch"); |
6b43d186eb8d
6722113: CMS: Incorrect overflow handling during precleaning of Reference lists
ysr
parents:
1388
diff
changeset
|
1845 |
} |
1 | 1846 |
|
1847 |
void do_void(); |
|
1848 |
}; |
|
1849 |
||
1850 |
// A parallel version of CMSDrainMarkingStackClosure above. |
|
1851 |
class CMSParDrainMarkingStackClosure: public VoidClosure { |
|
1852 |
CMSCollector* _collector; |
|
1853 |
MemRegion _span; |
|
1854 |
OopTaskQueue* _work_queue; |
|
1855 |
CMSBitMap* _bit_map; |
|
1856 |
CMSInnerParMarkAndPushClosure _mark_and_push; |
|
1857 |
||
1858 |
public: |
|
1859 |
CMSParDrainMarkingStackClosure(CMSCollector* collector, |
|
1860 |
MemRegion span, CMSBitMap* bit_map, |
|
1861 |
OopTaskQueue* work_queue): |
|
1862 |
_collector(collector), |
|
1863 |
_span(span), |
|
1864 |
_bit_map(bit_map), |
|
1865 |
_work_queue(work_queue), |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
1866 |
_mark_and_push(collector, span, bit_map, work_queue) { } |
1 | 1867 |
|
1868 |
public: |
|
1869 |
void trim_queue(uint max); |
|
1870 |
void do_void(); |
|
1871 |
}; |
|
1872 |
||
1873 |
// Allow yielding or short-circuiting of reference list |
|
22551 | 1874 |
// precleaning work. |
1 | 1875 |
class CMSPrecleanRefsYieldClosure: public YieldClosure { |
1876 |
CMSCollector* _collector; |
|
1877 |
void do_yield_work(); |
|
1878 |
public: |
|
1879 |
CMSPrecleanRefsYieldClosure(CMSCollector* collector): |
|
1880 |
_collector(collector) {} |
|
1881 |
virtual bool should_return(); |
|
1882 |
}; |
|
1883 |
||
1884 |
||
1885 |
// Convenience class that locks free list locks for given CMS collector |
|
1886 |
class FreelistLocker: public StackObj { |
|
1887 |
private: |
|
1888 |
CMSCollector* _collector; |
|
1889 |
public: |
|
1890 |
FreelistLocker(CMSCollector* collector): |
|
1891 |
_collector(collector) { |
|
1892 |
_collector->getFreelistLocks(); |
|
1893 |
} |
|
1894 |
||
1895 |
~FreelistLocker() { |
|
1896 |
_collector->releaseFreelistLocks(); |
|
1897 |
} |
|
1898 |
}; |
|
1899 |
||
1900 |
// Mark all dead objects in a given space. |
|
1901 |
class MarkDeadObjectsClosure: public BlkClosure { |
|
1902 |
const CMSCollector* _collector; |
|
1903 |
const CompactibleFreeListSpace* _sp; |
|
1904 |
CMSBitMap* _live_bit_map; |
|
1905 |
CMSBitMap* _dead_bit_map; |
|
1906 |
public: |
|
1907 |
MarkDeadObjectsClosure(const CMSCollector* collector, |
|
1908 |
const CompactibleFreeListSpace* sp, |
|
1909 |
CMSBitMap *live_bit_map, |
|
1910 |
CMSBitMap *dead_bit_map) : |
|
1911 |
_collector(collector), |
|
1912 |
_sp(sp), |
|
1913 |
_live_bit_map(live_bit_map), |
|
1914 |
_dead_bit_map(dead_bit_map) {} |
|
1915 |
size_t do_blk(HeapWord* addr); |
|
1916 |
}; |
|
6245
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
1917 |
|
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
1918 |
class TraceCMSMemoryManagerStats : public TraceMemoryManagerStats { |
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
1919 |
|
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
1920 |
public: |
9623
151c0b638488
7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
8688
diff
changeset
|
1921 |
TraceCMSMemoryManagerStats(CMSCollector::CollectorState phase, GCCause::Cause cause); |
6245
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
1922 |
}; |
c37d2cf6de1a
6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents:
5547
diff
changeset
|
1923 |
|
7397 | 1924 |
|
1925 |
#endif // SHARE_VM_GC_IMPLEMENTATION_CONCURRENTMARKSWEEP_CONCURRENTMARKSWEEPGENERATION_HPP |