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