annotate src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp @ 10405:f2110083203d

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