< prev index next >

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

Print this page




 179     GenCollectedHeap* gch = GenCollectedHeap::heap();
 180     gch->release_scratch();
 181   }
 182 
 183   _preserved_mark_stack.clear(true);
 184   _preserved_oop_stack.clear(true);
 185   _marking_stack.clear();
 186   _objarray_stack.clear(true);
 187 }
 188 
 189 void GenMarkSweep::mark_sweep_phase1(bool clear_all_softrefs) {
 190   // Recursively traverse all live objects and mark them
 191   GCTraceTime tm("phase 1", PrintGC && Verbose, true, _gc_timer);
 192 
 193   GenCollectedHeap* gch = GenCollectedHeap::heap();
 194 
 195   // Because follow_root_closure is created statically, cannot
 196   // use OopsInGenClosure constructor which takes a generation,
 197   // as the Universe has not been created when the static constructors
 198   // are run.
 199   follow_root_closure.set_orig_generation(gch->old_gen());
 200 
 201   // Need new claim bits before marking starts.
 202   ClassLoaderDataGraph::clear_claimed_marks();
 203 
 204   {
 205     StrongRootsScope srs(1);
 206 
 207     gch->gen_process_roots(&srs,
 208                            GenCollectedHeap::OldGen,
 209                            false, // Younger gens are not roots.
 210                            GenCollectedHeap::SO_None,
 211                            ClassUnloading,
 212                            &follow_root_closure,
 213                            &follow_root_closure,
 214                            &follow_cld_closure);
 215   }
 216 
 217   // Process reference objects found during marking
 218   {
 219     ref_processor()->setup_policy(clear_all_softrefs);
 220     const ReferenceProcessorStats& stats =
 221       ref_processor()->process_discovered_references(
 222         &is_alive, &keep_alive, &follow_stack_closure, NULL, _gc_timer);
 223     gc_tracer()->report_gc_reference_stats(stats);
 224   }
 225 
 226   // This is the point where the entire marking should have completed.
 227   assert(_marking_stack.is_empty(), "Marking should have completed");
 228 
 229   // Unload classes and purge the SystemDictionary.
 230   bool purged_class = SystemDictionary::do_unloading(&is_alive);
 231 
 232   // Unload nmethods.
 233   CodeCache::do_unloading(&is_alive, purged_class);


 269 class GenAdjustPointersClosure: public GenCollectedHeap::GenClosure {
 270 public:
 271   void do_generation(Generation* gen) {
 272     gen->adjust_pointers();
 273   }
 274 };
 275 
 276 void GenMarkSweep::mark_sweep_phase3() {
 277   GenCollectedHeap* gch = GenCollectedHeap::heap();
 278 
 279   // Adjust the pointers to reflect the new locations
 280   GCTraceTime tm("phase 3", PrintGC && Verbose, true, _gc_timer);
 281 
 282   // Need new claim bits for the pointer adjustment tracing.
 283   ClassLoaderDataGraph::clear_claimed_marks();
 284 
 285   // Because the closure below is created statically, we cannot
 286   // use OopsInGenClosure constructor which takes a generation,
 287   // as the Universe has not been created when the static constructors
 288   // are run.
 289   adjust_pointer_closure.set_orig_generation(gch->old_gen());
 290 
 291   {
 292     StrongRootsScope srs(1);
 293 
 294     gch->gen_process_roots(&srs,
 295                            GenCollectedHeap::OldGen,
 296                            false, // Younger gens are not roots.
 297                            GenCollectedHeap::SO_AllCodeCache,
 298                            GenCollectedHeap::StrongAndWeakRoots,
 299                            &adjust_pointer_closure,
 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     GenCollectedHeap* gch = GenCollectedHeap::heap();
 180     gch->release_scratch();
 181   }
 182 
 183   _preserved_mark_stack.clear(true);
 184   _preserved_oop_stack.clear(true);
 185   _marking_stack.clear();
 186   _objarray_stack.clear(true);
 187 }
 188 
 189 void GenMarkSweep::mark_sweep_phase1(bool clear_all_softrefs) {
 190   // Recursively traverse all live objects and mark them
 191   GCTraceTime tm("phase 1", PrintGC && Verbose, true, _gc_timer);
 192 
 193   GenCollectedHeap* gch = GenCollectedHeap::heap();
 194 
 195   // Because follow_root_closure is created statically, cannot
 196   // use OopsInGenClosure constructor which takes a generation,
 197   // as the Universe has not been created when the static constructors
 198   // are run.
 199   follow_root_closure.set_generation(gch->old_gen());
 200 
 201   // Need new claim bits before marking starts.
 202   ClassLoaderDataGraph::clear_claimed_marks();
 203 
 204   {
 205     StrongRootsScope srs(1);
 206 
 207     gch->old_process_roots(&srs,

 208                            false, // Younger gens are not roots.
 209                            GenCollectedHeap::SO_None,
 210                            ClassUnloading,
 211                            &follow_root_closure,

 212                            &follow_cld_closure);
 213   }
 214 
 215   // Process reference objects found during marking
 216   {
 217     ref_processor()->setup_policy(clear_all_softrefs);
 218     const ReferenceProcessorStats& stats =
 219       ref_processor()->process_discovered_references(
 220         &is_alive, &keep_alive, &follow_stack_closure, NULL, _gc_timer);
 221     gc_tracer()->report_gc_reference_stats(stats);
 222   }
 223 
 224   // This is the point where the entire marking should have completed.
 225   assert(_marking_stack.is_empty(), "Marking should have completed");
 226 
 227   // Unload classes and purge the SystemDictionary.
 228   bool purged_class = SystemDictionary::do_unloading(&is_alive);
 229 
 230   // Unload nmethods.
 231   CodeCache::do_unloading(&is_alive, purged_class);


 267 class GenAdjustPointersClosure: public GenCollectedHeap::GenClosure {
 268 public:
 269   void do_generation(Generation* gen) {
 270     gen->adjust_pointers();
 271   }
 272 };
 273 
 274 void GenMarkSweep::mark_sweep_phase3() {
 275   GenCollectedHeap* gch = GenCollectedHeap::heap();
 276 
 277   // Adjust the pointers to reflect the new locations
 278   GCTraceTime tm("phase 3", PrintGC && Verbose, true, _gc_timer);
 279 
 280   // Need new claim bits for the pointer adjustment tracing.
 281   ClassLoaderDataGraph::clear_claimed_marks();
 282 
 283   // Because the closure below is created statically, we cannot
 284   // use OopsInGenClosure constructor which takes a generation,
 285   // as the Universe has not been created when the static constructors
 286   // are run.
 287   adjust_pointer_closure.set_generation(gch->old_gen());
 288 
 289   {
 290     StrongRootsScope srs(1);
 291 
 292     gch->old_process_roots(&srs,

 293                            false, // Younger gens are not roots.
 294                            GenCollectedHeap::SO_AllCodeCache,
 295                            false, // Strong and weak roots.

 296                            &adjust_pointer_closure,
 297                            &adjust_cld_closure);
 298   }
 299 
 300   gch->gen_process_weak_roots(&adjust_pointer_closure);
 301 
 302   adjust_marks();
 303   GenAdjustPointersClosure blk;
 304   gch->generation_iterate(&blk, true);
 305 }
 306 
 307 class GenCompactClosure: public GenCollectedHeap::GenClosure {
 308 public:
 309   void do_generation(Generation* gen) {
 310     gen->compact();
 311   }
 312 };
 313 
 314 void GenMarkSweep::mark_sweep_phase4() {
 315   // All pointers are now adjusted, move objects accordingly
< prev index next >