annotate src/share/vm/gc_implementation/concurrentMarkSweep/cmsOopClosures.hpp @ 0:a61af66fc99e jdk7-b24

Initial load
author duke
date Sat, 01 Dec 2007 00:00:00 +0000
parents
children ba764ed4b6f2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
2 * Copyright (c) 2007 Sun Microsystems, Inc. All Rights Reserved.
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 *
a61af66fc99e Initial load
duke
parents:
diff changeset
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
a61af66fc99e Initial load
duke
parents:
diff changeset
20 * CA 95054 USA or visit www.sun.com if you need additional information or
a61af66fc99e Initial load
duke
parents:
diff changeset
21 * have any questions.
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 /////////////////////////////////////////////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
26 // Closures used by ConcurrentMarkSweepGeneration's collector
a61af66fc99e Initial load
duke
parents:
diff changeset
27 /////////////////////////////////////////////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
28 class ConcurrentMarkSweepGeneration;
a61af66fc99e Initial load
duke
parents:
diff changeset
29 class CMSBitMap;
a61af66fc99e Initial load
duke
parents:
diff changeset
30 class CMSMarkStack;
a61af66fc99e Initial load
duke
parents:
diff changeset
31 class CMSCollector;
a61af66fc99e Initial load
duke
parents:
diff changeset
32 template<class E> class GenericTaskQueue;
a61af66fc99e Initial load
duke
parents:
diff changeset
33 typedef GenericTaskQueue<oop> OopTaskQueue;
a61af66fc99e Initial load
duke
parents:
diff changeset
34 template<class E> class GenericTaskQueueSet;
a61af66fc99e Initial load
duke
parents:
diff changeset
35 typedef GenericTaskQueueSet<oop> OopTaskQueueSet;
a61af66fc99e Initial load
duke
parents:
diff changeset
36 class MarkFromRootsClosure;
a61af66fc99e Initial load
duke
parents:
diff changeset
37 class Par_MarkFromRootsClosure;
a61af66fc99e Initial load
duke
parents:
diff changeset
38
a61af66fc99e Initial load
duke
parents:
diff changeset
39 class MarkRefsIntoClosure: public OopsInGenClosure {
a61af66fc99e Initial load
duke
parents:
diff changeset
40 const MemRegion _span;
a61af66fc99e Initial load
duke
parents:
diff changeset
41 CMSBitMap* _bitMap;
a61af66fc99e Initial load
duke
parents:
diff changeset
42 const bool _should_do_nmethods;
a61af66fc99e Initial load
duke
parents:
diff changeset
43 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
44 MarkRefsIntoClosure(MemRegion span, CMSBitMap* bitMap,
a61af66fc99e Initial load
duke
parents:
diff changeset
45 bool should_do_nmethods);
a61af66fc99e Initial load
duke
parents:
diff changeset
46 void do_oop(oop* p);
a61af66fc99e Initial load
duke
parents:
diff changeset
47 void do_oop_nv(oop* p) { MarkRefsIntoClosure::do_oop(p); }
a61af66fc99e Initial load
duke
parents:
diff changeset
48 bool do_header() { return true; }
a61af66fc99e Initial load
duke
parents:
diff changeset
49 virtual const bool do_nmethods() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
50 return _should_do_nmethods;
a61af66fc99e Initial load
duke
parents:
diff changeset
51 }
a61af66fc99e Initial load
duke
parents:
diff changeset
52 Prefetch::style prefetch_style() {
a61af66fc99e Initial load
duke
parents:
diff changeset
53 return Prefetch::do_read;
a61af66fc99e Initial load
duke
parents:
diff changeset
54 }
a61af66fc99e Initial load
duke
parents:
diff changeset
55 };
a61af66fc99e Initial load
duke
parents:
diff changeset
56
a61af66fc99e Initial load
duke
parents:
diff changeset
57 // A variant of the above used in certain kinds of CMS
a61af66fc99e Initial load
duke
parents:
diff changeset
58 // marking verification.
a61af66fc99e Initial load
duke
parents:
diff changeset
59 class MarkRefsIntoVerifyClosure: public OopsInGenClosure {
a61af66fc99e Initial load
duke
parents:
diff changeset
60 const MemRegion _span;
a61af66fc99e Initial load
duke
parents:
diff changeset
61 CMSBitMap* _verification_bm;
a61af66fc99e Initial load
duke
parents:
diff changeset
62 CMSBitMap* _cms_bm;
a61af66fc99e Initial load
duke
parents:
diff changeset
63 const bool _should_do_nmethods;
a61af66fc99e Initial load
duke
parents:
diff changeset
64 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
65 MarkRefsIntoVerifyClosure(MemRegion span, CMSBitMap* verification_bm,
a61af66fc99e Initial load
duke
parents:
diff changeset
66 CMSBitMap* cms_bm, bool should_do_nmethods);
a61af66fc99e Initial load
duke
parents:
diff changeset
67 void do_oop(oop* p);
a61af66fc99e Initial load
duke
parents:
diff changeset
68 void do_oop_nv(oop* p) { MarkRefsIntoVerifyClosure::do_oop(p); }
a61af66fc99e Initial load
duke
parents:
diff changeset
69 bool do_header() { return true; }
a61af66fc99e Initial load
duke
parents:
diff changeset
70 virtual const bool do_nmethods() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
71 return _should_do_nmethods;
a61af66fc99e Initial load
duke
parents:
diff changeset
72 }
a61af66fc99e Initial load
duke
parents:
diff changeset
73 Prefetch::style prefetch_style() {
a61af66fc99e Initial load
duke
parents:
diff changeset
74 return Prefetch::do_read;
a61af66fc99e Initial load
duke
parents:
diff changeset
75 }
a61af66fc99e Initial load
duke
parents:
diff changeset
76 };
a61af66fc99e Initial load
duke
parents:
diff changeset
77
a61af66fc99e Initial load
duke
parents:
diff changeset
78
a61af66fc99e Initial load
duke
parents:
diff changeset
79 // The non-parallel version (the parallel version appears further below).
a61af66fc99e Initial load
duke
parents:
diff changeset
80 class PushAndMarkClosure: public OopClosure {
a61af66fc99e Initial load
duke
parents:
diff changeset
81 CMSCollector* _collector;
a61af66fc99e Initial load
duke
parents:
diff changeset
82 MemRegion _span;
a61af66fc99e Initial load
duke
parents:
diff changeset
83 CMSBitMap* _bit_map;
a61af66fc99e Initial load
duke
parents:
diff changeset
84 CMSBitMap* _mod_union_table;
a61af66fc99e Initial load
duke
parents:
diff changeset
85 CMSMarkStack* _mark_stack;
a61af66fc99e Initial load
duke
parents:
diff changeset
86 CMSMarkStack* _revisit_stack;
a61af66fc99e Initial load
duke
parents:
diff changeset
87 bool _concurrent_precleaning;
a61af66fc99e Initial load
duke
parents:
diff changeset
88 bool const _should_remember_klasses;
a61af66fc99e Initial load
duke
parents:
diff changeset
89 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
90 PushAndMarkClosure(CMSCollector* collector,
a61af66fc99e Initial load
duke
parents:
diff changeset
91 MemRegion span,
a61af66fc99e Initial load
duke
parents:
diff changeset
92 ReferenceProcessor* rp,
a61af66fc99e Initial load
duke
parents:
diff changeset
93 CMSBitMap* bit_map,
a61af66fc99e Initial load
duke
parents:
diff changeset
94 CMSBitMap* mod_union_table,
a61af66fc99e Initial load
duke
parents:
diff changeset
95 CMSMarkStack* mark_stack,
a61af66fc99e Initial load
duke
parents:
diff changeset
96 CMSMarkStack* revisit_stack,
a61af66fc99e Initial load
duke
parents:
diff changeset
97 bool concurrent_precleaning);
a61af66fc99e Initial load
duke
parents:
diff changeset
98
a61af66fc99e Initial load
duke
parents:
diff changeset
99 void do_oop(oop* p);
a61af66fc99e Initial load
duke
parents:
diff changeset
100 void do_oop_nv(oop* p) { PushAndMarkClosure::do_oop(p); }
a61af66fc99e Initial load
duke
parents:
diff changeset
101 bool do_header() { return true; }
a61af66fc99e Initial load
duke
parents:
diff changeset
102 Prefetch::style prefetch_style() {
a61af66fc99e Initial load
duke
parents:
diff changeset
103 return Prefetch::do_read;
a61af66fc99e Initial load
duke
parents:
diff changeset
104 }
a61af66fc99e Initial load
duke
parents:
diff changeset
105 const bool should_remember_klasses() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
106 return _should_remember_klasses;
a61af66fc99e Initial load
duke
parents:
diff changeset
107 }
a61af66fc99e Initial load
duke
parents:
diff changeset
108 void remember_klass(Klass* k);
a61af66fc99e Initial load
duke
parents:
diff changeset
109 };
a61af66fc99e Initial load
duke
parents:
diff changeset
110
a61af66fc99e Initial load
duke
parents:
diff changeset
111 // In the parallel case, the revisit stack, the bit map and the
a61af66fc99e Initial load
duke
parents:
diff changeset
112 // reference processor are currently all shared. Access to
a61af66fc99e Initial load
duke
parents:
diff changeset
113 // these shared mutable structures must use appropriate
a61af66fc99e Initial load
duke
parents:
diff changeset
114 // synchronization (for instance, via CAS). The marking stack
a61af66fc99e Initial load
duke
parents:
diff changeset
115 // used in the non-parallel case above is here replaced with
a61af66fc99e Initial load
duke
parents:
diff changeset
116 // an OopTaskQueue structure to allow efficient work stealing.
a61af66fc99e Initial load
duke
parents:
diff changeset
117 class Par_PushAndMarkClosure: public OopClosure {
a61af66fc99e Initial load
duke
parents:
diff changeset
118 CMSCollector* _collector;
a61af66fc99e Initial load
duke
parents:
diff changeset
119 MemRegion _span;
a61af66fc99e Initial load
duke
parents:
diff changeset
120 CMSBitMap* _bit_map;
a61af66fc99e Initial load
duke
parents:
diff changeset
121 OopTaskQueue* _work_queue;
a61af66fc99e Initial load
duke
parents:
diff changeset
122 CMSMarkStack* _revisit_stack;
a61af66fc99e Initial load
duke
parents:
diff changeset
123 bool const _should_remember_klasses;
a61af66fc99e Initial load
duke
parents:
diff changeset
124 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
125 Par_PushAndMarkClosure(CMSCollector* collector,
a61af66fc99e Initial load
duke
parents:
diff changeset
126 MemRegion span,
a61af66fc99e Initial load
duke
parents:
diff changeset
127 ReferenceProcessor* rp,
a61af66fc99e Initial load
duke
parents:
diff changeset
128 CMSBitMap* bit_map,
a61af66fc99e Initial load
duke
parents:
diff changeset
129 OopTaskQueue* work_queue,
a61af66fc99e Initial load
duke
parents:
diff changeset
130 CMSMarkStack* revisit_stack);
a61af66fc99e Initial load
duke
parents:
diff changeset
131
a61af66fc99e Initial load
duke
parents:
diff changeset
132 void do_oop(oop* p);
a61af66fc99e Initial load
duke
parents:
diff changeset
133 void do_oop_nv(oop* p) { Par_PushAndMarkClosure::do_oop(p); }
a61af66fc99e Initial load
duke
parents:
diff changeset
134 bool do_header() { return true; }
a61af66fc99e Initial load
duke
parents:
diff changeset
135 Prefetch::style prefetch_style() {
a61af66fc99e Initial load
duke
parents:
diff changeset
136 return Prefetch::do_read;
a61af66fc99e Initial load
duke
parents:
diff changeset
137 }
a61af66fc99e Initial load
duke
parents:
diff changeset
138 const bool should_remember_klasses() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
139 return _should_remember_klasses;
a61af66fc99e Initial load
duke
parents:
diff changeset
140 }
a61af66fc99e Initial load
duke
parents:
diff changeset
141 void remember_klass(Klass* k);
a61af66fc99e Initial load
duke
parents:
diff changeset
142 };
a61af66fc99e Initial load
duke
parents:
diff changeset
143
a61af66fc99e Initial load
duke
parents:
diff changeset
144
a61af66fc99e Initial load
duke
parents:
diff changeset
145 // The non-parallel version (the parallel version appears further below).
a61af66fc99e Initial load
duke
parents:
diff changeset
146 class MarkRefsIntoAndScanClosure: public OopsInGenClosure {
a61af66fc99e Initial load
duke
parents:
diff changeset
147 MemRegion _span;
a61af66fc99e Initial load
duke
parents:
diff changeset
148 CMSBitMap* _bit_map;
a61af66fc99e Initial load
duke
parents:
diff changeset
149 CMSMarkStack* _mark_stack;
a61af66fc99e Initial load
duke
parents:
diff changeset
150 PushAndMarkClosure _pushAndMarkClosure;
a61af66fc99e Initial load
duke
parents:
diff changeset
151 CMSCollector* _collector;
a61af66fc99e Initial load
duke
parents:
diff changeset
152 bool _yield;
a61af66fc99e Initial load
duke
parents:
diff changeset
153 // Whether closure is being used for concurrent precleaning
a61af66fc99e Initial load
duke
parents:
diff changeset
154 bool _concurrent_precleaning;
a61af66fc99e Initial load
duke
parents:
diff changeset
155 Mutex* _freelistLock;
a61af66fc99e Initial load
duke
parents:
diff changeset
156 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
157 MarkRefsIntoAndScanClosure(MemRegion span,
a61af66fc99e Initial load
duke
parents:
diff changeset
158 ReferenceProcessor* rp,
a61af66fc99e Initial load
duke
parents:
diff changeset
159 CMSBitMap* bit_map,
a61af66fc99e Initial load
duke
parents:
diff changeset
160 CMSBitMap* mod_union_table,
a61af66fc99e Initial load
duke
parents:
diff changeset
161 CMSMarkStack* mark_stack,
a61af66fc99e Initial load
duke
parents:
diff changeset
162 CMSMarkStack* revisit_stack,
a61af66fc99e Initial load
duke
parents:
diff changeset
163 CMSCollector* collector,
a61af66fc99e Initial load
duke
parents:
diff changeset
164 bool should_yield,
a61af66fc99e Initial load
duke
parents:
diff changeset
165 bool concurrent_precleaning);
a61af66fc99e Initial load
duke
parents:
diff changeset
166 void do_oop(oop* p);
a61af66fc99e Initial load
duke
parents:
diff changeset
167 void do_oop_nv(oop* p) { MarkRefsIntoAndScanClosure::do_oop(p); }
a61af66fc99e Initial load
duke
parents:
diff changeset
168 bool do_header() { return true; }
a61af66fc99e Initial load
duke
parents:
diff changeset
169 virtual const bool do_nmethods() const { return true; }
a61af66fc99e Initial load
duke
parents:
diff changeset
170 Prefetch::style prefetch_style() {
a61af66fc99e Initial load
duke
parents:
diff changeset
171 return Prefetch::do_read;
a61af66fc99e Initial load
duke
parents:
diff changeset
172 }
a61af66fc99e Initial load
duke
parents:
diff changeset
173 void set_freelistLock(Mutex* m) {
a61af66fc99e Initial load
duke
parents:
diff changeset
174 _freelistLock = m;
a61af66fc99e Initial load
duke
parents:
diff changeset
175 }
a61af66fc99e Initial load
duke
parents:
diff changeset
176
a61af66fc99e Initial load
duke
parents:
diff changeset
177 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
178 inline void do_yield_check();
a61af66fc99e Initial load
duke
parents:
diff changeset
179 void do_yield_work();
a61af66fc99e Initial load
duke
parents:
diff changeset
180 bool take_from_overflow_list();
a61af66fc99e Initial load
duke
parents:
diff changeset
181 };
a61af66fc99e Initial load
duke
parents:
diff changeset
182
a61af66fc99e Initial load
duke
parents:
diff changeset
183 // Tn this, the parallel avatar of MarkRefsIntoAndScanClosure, the revisit
a61af66fc99e Initial load
duke
parents:
diff changeset
184 // stack and the bitMap are shared, so access needs to be suitably
a61af66fc99e Initial load
duke
parents:
diff changeset
185 // sycnhronized. An OopTaskQueue structure, supporting efficient
a61af66fc99e Initial load
duke
parents:
diff changeset
186 // workstealing, replaces a CMSMarkStack for storing grey objects.
a61af66fc99e Initial load
duke
parents:
diff changeset
187 class Par_MarkRefsIntoAndScanClosure: public OopsInGenClosure {
a61af66fc99e Initial load
duke
parents:
diff changeset
188 MemRegion _span;
a61af66fc99e Initial load
duke
parents:
diff changeset
189 CMSBitMap* _bit_map;
a61af66fc99e Initial load
duke
parents:
diff changeset
190 OopTaskQueue* _work_queue;
a61af66fc99e Initial load
duke
parents:
diff changeset
191 const uint _low_water_mark;
a61af66fc99e Initial load
duke
parents:
diff changeset
192 Par_PushAndMarkClosure _par_pushAndMarkClosure;
a61af66fc99e Initial load
duke
parents:
diff changeset
193 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
194 Par_MarkRefsIntoAndScanClosure(CMSCollector* collector,
a61af66fc99e Initial load
duke
parents:
diff changeset
195 MemRegion span,
a61af66fc99e Initial load
duke
parents:
diff changeset
196 ReferenceProcessor* rp,
a61af66fc99e Initial load
duke
parents:
diff changeset
197 CMSBitMap* bit_map,
a61af66fc99e Initial load
duke
parents:
diff changeset
198 OopTaskQueue* work_queue,
a61af66fc99e Initial load
duke
parents:
diff changeset
199 CMSMarkStack* revisit_stack);
a61af66fc99e Initial load
duke
parents:
diff changeset
200 void do_oop(oop* p);
a61af66fc99e Initial load
duke
parents:
diff changeset
201 void do_oop_nv(oop* p) { Par_MarkRefsIntoAndScanClosure::do_oop(p); }
a61af66fc99e Initial load
duke
parents:
diff changeset
202 bool do_header() { return true; }
a61af66fc99e Initial load
duke
parents:
diff changeset
203 virtual const bool do_nmethods() const { return true; }
a61af66fc99e Initial load
duke
parents:
diff changeset
204 Prefetch::style prefetch_style() {
a61af66fc99e Initial load
duke
parents:
diff changeset
205 return Prefetch::do_read;
a61af66fc99e Initial load
duke
parents:
diff changeset
206 }
a61af66fc99e Initial load
duke
parents:
diff changeset
207 void trim_queue(uint size);
a61af66fc99e Initial load
duke
parents:
diff changeset
208 };
a61af66fc99e Initial load
duke
parents:
diff changeset
209
a61af66fc99e Initial load
duke
parents:
diff changeset
210 // This closure is used during the concurrent marking phase
a61af66fc99e Initial load
duke
parents:
diff changeset
211 // following the first checkpoint. Its use is buried in
a61af66fc99e Initial load
duke
parents:
diff changeset
212 // the closure MarkFromRootsClosure.
a61af66fc99e Initial load
duke
parents:
diff changeset
213 class PushOrMarkClosure: public OopClosure {
a61af66fc99e Initial load
duke
parents:
diff changeset
214 CMSCollector* _collector;
a61af66fc99e Initial load
duke
parents:
diff changeset
215 MemRegion _span;
a61af66fc99e Initial load
duke
parents:
diff changeset
216 CMSBitMap* _bitMap;
a61af66fc99e Initial load
duke
parents:
diff changeset
217 CMSMarkStack* _markStack;
a61af66fc99e Initial load
duke
parents:
diff changeset
218 CMSMarkStack* _revisitStack;
a61af66fc99e Initial load
duke
parents:
diff changeset
219 HeapWord* const _finger;
a61af66fc99e Initial load
duke
parents:
diff changeset
220 MarkFromRootsClosure* const _parent;
a61af66fc99e Initial load
duke
parents:
diff changeset
221 bool const _should_remember_klasses;
a61af66fc99e Initial load
duke
parents:
diff changeset
222 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
223 PushOrMarkClosure(CMSCollector* cms_collector,
a61af66fc99e Initial load
duke
parents:
diff changeset
224 MemRegion span,
a61af66fc99e Initial load
duke
parents:
diff changeset
225 CMSBitMap* bitMap,
a61af66fc99e Initial load
duke
parents:
diff changeset
226 CMSMarkStack* markStack,
a61af66fc99e Initial load
duke
parents:
diff changeset
227 CMSMarkStack* revisitStack,
a61af66fc99e Initial load
duke
parents:
diff changeset
228 HeapWord* finger,
a61af66fc99e Initial load
duke
parents:
diff changeset
229 MarkFromRootsClosure* parent);
a61af66fc99e Initial load
duke
parents:
diff changeset
230 void do_oop(oop* p);
a61af66fc99e Initial load
duke
parents:
diff changeset
231 void do_oop_nv(oop* p) { PushOrMarkClosure::do_oop(p); }
a61af66fc99e Initial load
duke
parents:
diff changeset
232 const bool should_remember_klasses() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
233 return _should_remember_klasses;
a61af66fc99e Initial load
duke
parents:
diff changeset
234 }
a61af66fc99e Initial load
duke
parents:
diff changeset
235 void remember_klass(Klass* k);
a61af66fc99e Initial load
duke
parents:
diff changeset
236 // Deal with a stack overflow condition
a61af66fc99e Initial load
duke
parents:
diff changeset
237 void handle_stack_overflow(HeapWord* lost);
a61af66fc99e Initial load
duke
parents:
diff changeset
238 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
239 inline void do_yield_check();
a61af66fc99e Initial load
duke
parents:
diff changeset
240 };
a61af66fc99e Initial load
duke
parents:
diff changeset
241
a61af66fc99e Initial load
duke
parents:
diff changeset
242 // A parallel (MT) version of the above.
a61af66fc99e Initial load
duke
parents:
diff changeset
243 // This closure is used during the concurrent marking phase
a61af66fc99e Initial load
duke
parents:
diff changeset
244 // following the first checkpoint. Its use is buried in
a61af66fc99e Initial load
duke
parents:
diff changeset
245 // the closure Par_MarkFromRootsClosure.
a61af66fc99e Initial load
duke
parents:
diff changeset
246 class Par_PushOrMarkClosure: public OopClosure {
a61af66fc99e Initial load
duke
parents:
diff changeset
247 CMSCollector* _collector;
a61af66fc99e Initial load
duke
parents:
diff changeset
248 MemRegion _whole_span;
a61af66fc99e Initial load
duke
parents:
diff changeset
249 MemRegion _span; // local chunk
a61af66fc99e Initial load
duke
parents:
diff changeset
250 CMSBitMap* _bit_map;
a61af66fc99e Initial load
duke
parents:
diff changeset
251 OopTaskQueue* _work_queue;
a61af66fc99e Initial load
duke
parents:
diff changeset
252 CMSMarkStack* _overflow_stack;
a61af66fc99e Initial load
duke
parents:
diff changeset
253 CMSMarkStack* _revisit_stack;
a61af66fc99e Initial load
duke
parents:
diff changeset
254 HeapWord* const _finger;
a61af66fc99e Initial load
duke
parents:
diff changeset
255 HeapWord** const _global_finger_addr;
a61af66fc99e Initial load
duke
parents:
diff changeset
256 Par_MarkFromRootsClosure* const _parent;
a61af66fc99e Initial load
duke
parents:
diff changeset
257 bool const _should_remember_klasses;
a61af66fc99e Initial load
duke
parents:
diff changeset
258 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
259 Par_PushOrMarkClosure(CMSCollector* cms_collector,
a61af66fc99e Initial load
duke
parents:
diff changeset
260 MemRegion span,
a61af66fc99e Initial load
duke
parents:
diff changeset
261 CMSBitMap* bit_map,
a61af66fc99e Initial load
duke
parents:
diff changeset
262 OopTaskQueue* work_queue,
a61af66fc99e Initial load
duke
parents:
diff changeset
263 CMSMarkStack* mark_stack,
a61af66fc99e Initial load
duke
parents:
diff changeset
264 CMSMarkStack* revisit_stack,
a61af66fc99e Initial load
duke
parents:
diff changeset
265 HeapWord* finger,
a61af66fc99e Initial load
duke
parents:
diff changeset
266 HeapWord** global_finger_addr,
a61af66fc99e Initial load
duke
parents:
diff changeset
267 Par_MarkFromRootsClosure* parent);
a61af66fc99e Initial load
duke
parents:
diff changeset
268 void do_oop(oop* p);
a61af66fc99e Initial load
duke
parents:
diff changeset
269 void do_oop_nv(oop* p) { Par_PushOrMarkClosure::do_oop(p); }
a61af66fc99e Initial load
duke
parents:
diff changeset
270 const bool should_remember_klasses() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
271 return _should_remember_klasses;
a61af66fc99e Initial load
duke
parents:
diff changeset
272 }
a61af66fc99e Initial load
duke
parents:
diff changeset
273 void remember_klass(Klass* k);
a61af66fc99e Initial load
duke
parents:
diff changeset
274 // Deal with a stack overflow condition
a61af66fc99e Initial load
duke
parents:
diff changeset
275 void handle_stack_overflow(HeapWord* lost);
a61af66fc99e Initial load
duke
parents:
diff changeset
276 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
277 inline void do_yield_check();
a61af66fc99e Initial load
duke
parents:
diff changeset
278 };
a61af66fc99e Initial load
duke
parents:
diff changeset
279
a61af66fc99e Initial load
duke
parents:
diff changeset
280 // For objects in CMS generation, this closure marks
a61af66fc99e Initial load
duke
parents:
diff changeset
281 // given objects (transitively) as being reachable/live.
a61af66fc99e Initial load
duke
parents:
diff changeset
282 // This is currently used during the (weak) reference object
a61af66fc99e Initial load
duke
parents:
diff changeset
283 // processing phase of the CMS final checkpoint step.
a61af66fc99e Initial load
duke
parents:
diff changeset
284 class CMSKeepAliveClosure: public OopClosure {
a61af66fc99e Initial load
duke
parents:
diff changeset
285 CMSCollector* _collector;
a61af66fc99e Initial load
duke
parents:
diff changeset
286 MemRegion _span;
a61af66fc99e Initial load
duke
parents:
diff changeset
287 CMSMarkStack* _mark_stack;
a61af66fc99e Initial load
duke
parents:
diff changeset
288 CMSBitMap* _bit_map;
a61af66fc99e Initial load
duke
parents:
diff changeset
289 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
290 CMSKeepAliveClosure(CMSCollector* collector, MemRegion span,
a61af66fc99e Initial load
duke
parents:
diff changeset
291 CMSBitMap* bit_map, CMSMarkStack* mark_stack):
a61af66fc99e Initial load
duke
parents:
diff changeset
292 _collector(collector),
a61af66fc99e Initial load
duke
parents:
diff changeset
293 _span(span),
a61af66fc99e Initial load
duke
parents:
diff changeset
294 _bit_map(bit_map),
a61af66fc99e Initial load
duke
parents:
diff changeset
295 _mark_stack(mark_stack) { }
a61af66fc99e Initial load
duke
parents:
diff changeset
296
a61af66fc99e Initial load
duke
parents:
diff changeset
297 void do_oop(oop* p);
a61af66fc99e Initial load
duke
parents:
diff changeset
298 void do_oop_nv(oop* p) { CMSKeepAliveClosure::do_oop(p); }
a61af66fc99e Initial load
duke
parents:
diff changeset
299 };
a61af66fc99e Initial load
duke
parents:
diff changeset
300
a61af66fc99e Initial load
duke
parents:
diff changeset
301 class CMSInnerParMarkAndPushClosure: public OopClosure {
a61af66fc99e Initial load
duke
parents:
diff changeset
302 CMSCollector* _collector;
a61af66fc99e Initial load
duke
parents:
diff changeset
303 MemRegion _span;
a61af66fc99e Initial load
duke
parents:
diff changeset
304 OopTaskQueue* _work_queue;
a61af66fc99e Initial load
duke
parents:
diff changeset
305 CMSBitMap* _bit_map;
a61af66fc99e Initial load
duke
parents:
diff changeset
306 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
307 CMSInnerParMarkAndPushClosure(CMSCollector* collector,
a61af66fc99e Initial load
duke
parents:
diff changeset
308 MemRegion span, CMSBitMap* bit_map,
a61af66fc99e Initial load
duke
parents:
diff changeset
309 OopTaskQueue* work_queue):
a61af66fc99e Initial load
duke
parents:
diff changeset
310 _collector(collector),
a61af66fc99e Initial load
duke
parents:
diff changeset
311 _span(span),
a61af66fc99e Initial load
duke
parents:
diff changeset
312 _bit_map(bit_map),
a61af66fc99e Initial load
duke
parents:
diff changeset
313 _work_queue(work_queue) { }
a61af66fc99e Initial load
duke
parents:
diff changeset
314 void do_oop(oop* p);
a61af66fc99e Initial load
duke
parents:
diff changeset
315 void do_oop_nv(oop* p) { CMSInnerParMarkAndPushClosure::do_oop(p); }
a61af66fc99e Initial load
duke
parents:
diff changeset
316 };
a61af66fc99e Initial load
duke
parents:
diff changeset
317
a61af66fc99e Initial load
duke
parents:
diff changeset
318 // A parallel (MT) version of the above, used when
a61af66fc99e Initial load
duke
parents:
diff changeset
319 // reference processing is parallel; the only difference
a61af66fc99e Initial load
duke
parents:
diff changeset
320 // is in the do_oop method.
a61af66fc99e Initial load
duke
parents:
diff changeset
321 class CMSParKeepAliveClosure: public OopClosure {
a61af66fc99e Initial load
duke
parents:
diff changeset
322 CMSCollector* _collector;
a61af66fc99e Initial load
duke
parents:
diff changeset
323 MemRegion _span;
a61af66fc99e Initial load
duke
parents:
diff changeset
324 OopTaskQueue* _work_queue;
a61af66fc99e Initial load
duke
parents:
diff changeset
325 CMSBitMap* _bit_map;
a61af66fc99e Initial load
duke
parents:
diff changeset
326 CMSInnerParMarkAndPushClosure _mark_and_push;
a61af66fc99e Initial load
duke
parents:
diff changeset
327 const uint _low_water_mark;
a61af66fc99e Initial load
duke
parents:
diff changeset
328 void trim_queue(uint max);
a61af66fc99e Initial load
duke
parents:
diff changeset
329 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
330 CMSParKeepAliveClosure(CMSCollector* collector, MemRegion span,
a61af66fc99e Initial load
duke
parents:
diff changeset
331 CMSBitMap* bit_map, OopTaskQueue* work_queue);
a61af66fc99e Initial load
duke
parents:
diff changeset
332 void do_oop(oop* p);
a61af66fc99e Initial load
duke
parents:
diff changeset
333 void do_oop_nv(oop* p) { CMSParKeepAliveClosure::do_oop(p); }
a61af66fc99e Initial load
duke
parents:
diff changeset
334 };