180
181 void GenMarkSweep::mark_sweep_phase1(bool clear_all_softrefs) {
182 // Recursively traverse all live objects and mark them
183 GCTraceTime(Info, gc, phases) tm("Phase 1: Mark live objects", _gc_timer);
184
185 GenCollectedHeap* gch = GenCollectedHeap::heap();
186
187 // Because follow_root_closure is created statically, cannot
188 // use OopsInGenClosure constructor which takes a generation,
189 // as the Universe has not been created when the static constructors
190 // are run.
191 follow_root_closure.set_orig_generation(gch->old_gen());
192
193 // Need new claim bits before marking starts.
194 ClassLoaderDataGraph::clear_claimed_marks();
195
196 {
197 StrongRootsScope srs(1);
198
199 gch->full_process_roots(&srs,
200 ClassUnloading, // only strong roots if ClassUnloading
201 // is enabled
202 GenCollectedHeap::SO_None,
203 false, // not the adjust phase
204 &follow_root_closure,
205 &follow_cld_closure);
206 }
207
208 // Process reference objects found during marking
209 {
210 GCTraceTime(Debug, gc, phases) tm_m("Reference Processing", gc_timer());
211
212 ref_processor()->setup_policy(clear_all_softrefs);
213 const ReferenceProcessorStats& stats =
214 ref_processor()->process_discovered_references(
215 &is_alive, &keep_alive, &follow_stack_closure, NULL, _gc_timer);
216 gc_tracer()->report_gc_reference_stats(stats);
217 }
218
219 // This is the point where the entire marking should have completed.
220 assert(_marking_stack.is_empty(), "Marking should have completed");
221
222 {
223 GCTraceTime(Debug, gc, phases) tm_m("Class Unloading", gc_timer());
278
279 void GenMarkSweep::mark_sweep_phase3() {
280 GenCollectedHeap* gch = GenCollectedHeap::heap();
281
282 // Adjust the pointers to reflect the new locations
283 GCTraceTime(Info, gc, phases) tm("Phase 3: Adjust pointers", gc_timer());
284
285 // Need new claim bits for the pointer adjustment tracing.
286 ClassLoaderDataGraph::clear_claimed_marks();
287
288 // Because the closure below is created statically, we cannot
289 // use OopsInGenClosure constructor which takes a generation,
290 // as the Universe has not been created when the static constructors
291 // are run.
292 adjust_pointer_closure.set_orig_generation(gch->old_gen());
293
294 {
295 StrongRootsScope srs(1);
296
297 gch->full_process_roots(&srs,
298 false, // all roots
299 GenCollectedHeap::SO_AllCodeCache,
300 true, // this is the adjust phase
301 &adjust_pointer_closure,
302 &adjust_cld_closure);
303 }
304
305 gch->gen_process_weak_roots(&adjust_pointer_closure);
306
307 adjust_marks();
308 GenAdjustPointersClosure blk;
309 gch->generation_iterate(&blk, true);
310 }
311
312 class GenCompactClosure: public GenCollectedHeap::GenClosure {
313 public:
314 void do_generation(Generation* gen) {
315 gen->compact();
316 }
317 };
318
319 void GenMarkSweep::mark_sweep_phase4() {
320 // All pointers are now adjusted, move objects accordingly
|
180
181 void GenMarkSweep::mark_sweep_phase1(bool clear_all_softrefs) {
182 // Recursively traverse all live objects and mark them
183 GCTraceTime(Info, gc, phases) tm("Phase 1: Mark live objects", _gc_timer);
184
185 GenCollectedHeap* gch = GenCollectedHeap::heap();
186
187 // Because follow_root_closure is created statically, cannot
188 // use OopsInGenClosure constructor which takes a generation,
189 // as the Universe has not been created when the static constructors
190 // are run.
191 follow_root_closure.set_orig_generation(gch->old_gen());
192
193 // Need new claim bits before marking starts.
194 ClassLoaderDataGraph::clear_claimed_marks();
195
196 {
197 StrongRootsScope srs(1);
198
199 gch->full_process_roots(&srs,
200 false, // not the adjust phase
201 GenCollectedHeap::SO_None,
202 ClassUnloading, // only strong roots if ClassUnloading
203 // is enabled
204 &follow_root_closure,
205 &follow_cld_closure);
206 }
207
208 // Process reference objects found during marking
209 {
210 GCTraceTime(Debug, gc, phases) tm_m("Reference Processing", gc_timer());
211
212 ref_processor()->setup_policy(clear_all_softrefs);
213 const ReferenceProcessorStats& stats =
214 ref_processor()->process_discovered_references(
215 &is_alive, &keep_alive, &follow_stack_closure, NULL, _gc_timer);
216 gc_tracer()->report_gc_reference_stats(stats);
217 }
218
219 // This is the point where the entire marking should have completed.
220 assert(_marking_stack.is_empty(), "Marking should have completed");
221
222 {
223 GCTraceTime(Debug, gc, phases) tm_m("Class Unloading", gc_timer());
278
279 void GenMarkSweep::mark_sweep_phase3() {
280 GenCollectedHeap* gch = GenCollectedHeap::heap();
281
282 // Adjust the pointers to reflect the new locations
283 GCTraceTime(Info, gc, phases) tm("Phase 3: Adjust pointers", gc_timer());
284
285 // Need new claim bits for the pointer adjustment tracing.
286 ClassLoaderDataGraph::clear_claimed_marks();
287
288 // Because the closure below is created statically, we cannot
289 // use OopsInGenClosure constructor which takes a generation,
290 // as the Universe has not been created when the static constructors
291 // are run.
292 adjust_pointer_closure.set_orig_generation(gch->old_gen());
293
294 {
295 StrongRootsScope srs(1);
296
297 gch->full_process_roots(&srs,
298 true, // this is the adjust phase
299 GenCollectedHeap::SO_AllCodeCache,
300 false, // all roots
301 &adjust_pointer_closure,
302 &adjust_cld_closure);
303 }
304
305 gch->gen_process_weak_roots(&adjust_pointer_closure);
306
307 adjust_marks();
308 GenAdjustPointersClosure blk;
309 gch->generation_iterate(&blk, true);
310 }
311
312 class GenCompactClosure: public GenCollectedHeap::GenClosure {
313 public:
314 void do_generation(Generation* gen) {
315 gen->compact();
316 }
317 };
318
319 void GenMarkSweep::mark_sweep_phase4() {
320 // All pointers are now adjusted, move objects accordingly
|