< 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
rev 11985 : 8165949: Serial and ConcMarkSweep do not unload strings when class unloading is disabled
Reviewed-by:


 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());


 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


 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->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());


 277 };
 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
< prev index next >