193 void GenMarkSweep::mark_sweep_phase1(int level,
194 bool clear_all_softrefs) {
195 // Recursively traverse all live objects and mark them
196 GCTraceTime tm("phase 1", PrintGC && Verbose, true, _gc_timer, _gc_tracer->gc_id());
197 trace(" 1");
198
199 GenCollectedHeap* gch = GenCollectedHeap::heap();
200
201 // Because follow_root_closure is created statically, cannot
202 // use OopsInGenClosure constructor which takes a generation,
203 // as the Universe has not been created when the static constructors
204 // are run.
205 follow_root_closure.set_orig_generation(gch->get_gen(level));
206
207 // Need new claim bits before marking starts.
208 ClassLoaderDataGraph::clear_claimed_marks();
209
210 gch->gen_process_roots(level,
211 false, // Younger gens are not roots.
212 true, // activate StrongRootsScope
213 SharedHeap::SO_None,
214 GenCollectedHeap::StrongRootsOnly,
215 &follow_root_closure,
216 &follow_root_closure,
217 &follow_cld_closure);
218
219 // Process reference objects found during marking
220 {
221 ref_processor()->setup_policy(clear_all_softrefs);
222 const ReferenceProcessorStats& stats =
223 ref_processor()->process_discovered_references(
224 &is_alive, &keep_alive, &follow_stack_closure, NULL, _gc_timer, _gc_tracer->gc_id());
225 gc_tracer()->report_gc_reference_stats(stats);
226 }
227
228 // This is the point where the entire marking should have completed.
229 assert(_marking_stack.is_empty(), "Marking should have completed");
230
231 // Unload classes and purge the SystemDictionary.
232 bool purged_class = SystemDictionary::do_unloading(&is_alive);
233
278
279 void GenMarkSweep::mark_sweep_phase3(int level) {
280 GenCollectedHeap* gch = GenCollectedHeap::heap();
281
282 // Adjust the pointers to reflect the new locations
283 GCTraceTime tm("phase 3", PrintGC && Verbose, true, _gc_timer, _gc_tracer->gc_id());
284 trace("3");
285
286 // Need new claim bits for the pointer adjustment tracing.
287 ClassLoaderDataGraph::clear_claimed_marks();
288
289 // Because the closure below is created statically, we cannot
290 // use OopsInGenClosure constructor which takes a generation,
291 // as the Universe has not been created when the static constructors
292 // are run.
293 adjust_pointer_closure.set_orig_generation(gch->get_gen(level));
294
295 gch->gen_process_roots(level,
296 false, // Younger gens are not roots.
297 true, // activate StrongRootsScope
298 SharedHeap::SO_AllCodeCache,
299 GenCollectedHeap::StrongAndWeakRoots,
300 &adjust_pointer_closure,
301 &adjust_pointer_closure,
302 &adjust_cld_closure);
303
304 gch->gen_process_weak_roots(&adjust_pointer_closure);
305
306 adjust_marks();
307 GenAdjustPointersClosure blk;
308 gch->generation_iterate(&blk, true);
309 }
310
311 class GenCompactClosure: public GenCollectedHeap::GenClosure {
312 public:
313 void do_generation(Generation* gen) {
314 gen->compact();
315 }
316 };
317
318 void GenMarkSweep::mark_sweep_phase4() {
|
193 void GenMarkSweep::mark_sweep_phase1(int level,
194 bool clear_all_softrefs) {
195 // Recursively traverse all live objects and mark them
196 GCTraceTime tm("phase 1", PrintGC && Verbose, true, _gc_timer, _gc_tracer->gc_id());
197 trace(" 1");
198
199 GenCollectedHeap* gch = GenCollectedHeap::heap();
200
201 // Because follow_root_closure is created statically, cannot
202 // use OopsInGenClosure constructor which takes a generation,
203 // as the Universe has not been created when the static constructors
204 // are run.
205 follow_root_closure.set_orig_generation(gch->get_gen(level));
206
207 // Need new claim bits before marking starts.
208 ClassLoaderDataGraph::clear_claimed_marks();
209
210 gch->gen_process_roots(level,
211 false, // Younger gens are not roots.
212 true, // activate StrongRootsScope
213 GenCollectedHeap::SO_None,
214 GenCollectedHeap::StrongRootsOnly,
215 &follow_root_closure,
216 &follow_root_closure,
217 &follow_cld_closure);
218
219 // Process reference objects found during marking
220 {
221 ref_processor()->setup_policy(clear_all_softrefs);
222 const ReferenceProcessorStats& stats =
223 ref_processor()->process_discovered_references(
224 &is_alive, &keep_alive, &follow_stack_closure, NULL, _gc_timer, _gc_tracer->gc_id());
225 gc_tracer()->report_gc_reference_stats(stats);
226 }
227
228 // This is the point where the entire marking should have completed.
229 assert(_marking_stack.is_empty(), "Marking should have completed");
230
231 // Unload classes and purge the SystemDictionary.
232 bool purged_class = SystemDictionary::do_unloading(&is_alive);
233
278
279 void GenMarkSweep::mark_sweep_phase3(int level) {
280 GenCollectedHeap* gch = GenCollectedHeap::heap();
281
282 // Adjust the pointers to reflect the new locations
283 GCTraceTime tm("phase 3", PrintGC && Verbose, true, _gc_timer, _gc_tracer->gc_id());
284 trace("3");
285
286 // Need new claim bits for the pointer adjustment tracing.
287 ClassLoaderDataGraph::clear_claimed_marks();
288
289 // Because the closure below is created statically, we cannot
290 // use OopsInGenClosure constructor which takes a generation,
291 // as the Universe has not been created when the static constructors
292 // are run.
293 adjust_pointer_closure.set_orig_generation(gch->get_gen(level));
294
295 gch->gen_process_roots(level,
296 false, // Younger gens are not roots.
297 true, // activate StrongRootsScope
298 GenCollectedHeap::SO_AllCodeCache,
299 GenCollectedHeap::StrongAndWeakRoots,
300 &adjust_pointer_closure,
301 &adjust_pointer_closure,
302 &adjust_cld_closure);
303
304 gch->gen_process_weak_roots(&adjust_pointer_closure);
305
306 adjust_marks();
307 GenAdjustPointersClosure blk;
308 gch->generation_iterate(&blk, true);
309 }
310
311 class GenCompactClosure: public GenCollectedHeap::GenClosure {
312 public:
313 void do_generation(Generation* gen) {
314 gen->compact();
315 }
316 };
317
318 void GenMarkSweep::mark_sweep_phase4() {
|