< prev index next >

src/share/vm/gc/serial/genMarkSweep.cpp

Print this page
rev 11983 : 8166276: Refactor gen_process_roots to allow simpler fix for 8165949
Reviewed-by:
Contributed-by: jesper.wilhelmsson@oracle.com


 179 }
 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->gen_process_roots(&srs,
 200                            GenCollectedHeap::OldGen,
 201                            false, // Younger gens are not roots.
 202                            GenCollectedHeap::SO_None,
 203                            ClassUnloading,
 204                            &follow_root_closure,
 205                            &follow_root_closure,
 206                            &follow_cld_closure);
 207   }
 208 
 209   // Process reference objects found during marking
 210   {
 211     GCTraceTime(Debug, gc, phases) tm_m("Reference Processing", gc_timer());
 212 
 213     ref_processor()->setup_policy(clear_all_softrefs);
 214     const ReferenceProcessorStats& stats =
 215       ref_processor()->process_discovered_references(
 216         &is_alive, &keep_alive, &follow_stack_closure, NULL, _gc_timer);
 217     gc_tracer()->report_gc_reference_stats(stats);
 218   }
 219 
 220   // This is the point where the entire marking should have completed.
 221   assert(_marking_stack.is_empty(), "Marking should have completed");
 222 
 223   {
 224     GCTraceTime(Debug, gc, phases) tm_m("Class Unloading", gc_timer());
 225 


 278 };
 279 
 280 void GenMarkSweep::mark_sweep_phase3() {
 281   GenCollectedHeap* gch = GenCollectedHeap::heap();
 282 
 283   // Adjust the pointers to reflect the new locations
 284   GCTraceTime(Info, gc, phases) tm("Phase 3: Adjust pointers", gc_timer());
 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->old_gen());
 294 
 295   {
 296     StrongRootsScope srs(1);
 297 
 298     gch->gen_process_roots(&srs,
 299                            GenCollectedHeap::OldGen,
 300                            false, // Younger gens are not roots.
 301                            GenCollectedHeap::SO_AllCodeCache,
 302                            GenCollectedHeap::StrongAndWeakRoots,
 303                            &adjust_pointer_closure,
 304                            &adjust_pointer_closure,
 305                            &adjust_cld_closure);
 306   }
 307 
 308   gch->gen_process_weak_roots(&adjust_pointer_closure);
 309 
 310   adjust_marks();
 311   GenAdjustPointersClosure blk;
 312   gch->generation_iterate(&blk, true);
 313 }
 314 
 315 class GenCompactClosure: public GenCollectedHeap::GenClosure {
 316 public:
 317   void do_generation(Generation* gen) {
 318     gen->compact();
 319   }
 320 };
 321 
 322 void GenMarkSweep::mark_sweep_phase4() {
 323   // All pointers are now adjusted, move objects accordingly


 179 }
 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->old_process_roots(&srs,

 200                            false, // Younger gens are not roots.
 201                            GenCollectedHeap::SO_None,
 202                            ClassUnloading,
 203                            &follow_root_closure,

 204                            &follow_cld_closure);
 205   }
 206 
 207   // Process reference objects found during marking
 208   {
 209     GCTraceTime(Debug, gc, phases) tm_m("Reference Processing", gc_timer());
 210 
 211     ref_processor()->setup_policy(clear_all_softrefs);
 212     const ReferenceProcessorStats& stats =
 213       ref_processor()->process_discovered_references(
 214         &is_alive, &keep_alive, &follow_stack_closure, NULL, _gc_timer);
 215     gc_tracer()->report_gc_reference_stats(stats);
 216   }
 217 
 218   // This is the point where the entire marking should have completed.
 219   assert(_marking_stack.is_empty(), "Marking should have completed");
 220 
 221   {
 222     GCTraceTime(Debug, gc, phases) tm_m("Class Unloading", gc_timer());
 223 


 276 };
 277 
 278 void GenMarkSweep::mark_sweep_phase3() {
 279   GenCollectedHeap* gch = GenCollectedHeap::heap();
 280 
 281   // Adjust the pointers to reflect the new locations
 282   GCTraceTime(Info, gc, phases) tm("Phase 3: Adjust pointers", gc_timer());
 283 
 284   // Need new claim bits for the pointer adjustment tracing.
 285   ClassLoaderDataGraph::clear_claimed_marks();
 286 
 287   // Because the closure below is created statically, we cannot
 288   // use OopsInGenClosure constructor which takes a generation,
 289   // as the Universe has not been created when the static constructors
 290   // are run.
 291   adjust_pointer_closure.set_orig_generation(gch->old_gen());
 292 
 293   {
 294     StrongRootsScope srs(1);
 295 
 296     gch->old_process_roots(&srs,

 297                            false, // Younger gens are not roots.
 298                            GenCollectedHeap::SO_AllCodeCache,
 299                            false,

 300                            &adjust_pointer_closure,
 301                            &adjust_cld_closure);
 302   }
 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() {
 319   // All pointers are now adjusted, move objects accordingly
< prev index next >