src/share/vm/gc_implementation/parallelScavenge/psScavenge.cpp

Print this page




 246 
 247     if (UseParallelOldGC) {
 248       full_gc_done = PSParallelCompact::invoke_no_policy(clear_all_softrefs);
 249     } else {
 250       full_gc_done = PSMarkSweep::invoke_no_policy(clear_all_softrefs);
 251     }
 252   }
 253 
 254   return full_gc_done;
 255 }
 256 
 257 // This method contains no policy. You should probably
 258 // be calling invoke() instead.
 259 bool PSScavenge::invoke_no_policy() {
 260   assert(SafepointSynchronize::is_at_safepoint(), "should be at safepoint");
 261   assert(Thread::current() == (Thread*)VMThread::vm_thread(), "should be in vm thread");
 262 
 263   assert(_preserved_mark_stack.is_empty(), "should be empty");
 264   assert(_preserved_oop_stack.is_empty(), "should be empty");
 265 
 266   _gc_timer.register_gc_start(os::elapsed_counter());
 267 
 268   TimeStamp scavenge_entry;
 269   TimeStamp scavenge_midpoint;
 270   TimeStamp scavenge_exit;
 271 
 272   scavenge_entry.update();
 273 
 274   if (GC_locker::check_active_before_gc()) {
 275     return false;
 276   }
 277 
 278   ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
 279   GCCause::Cause gc_cause = heap->gc_cause();
 280   assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity");
 281 
 282   // Check for potential problems.
 283   if (!should_attempt_scavenge()) {
 284     return false;
 285   }
 286 


 674   if (ZapUnusedHeapArea) {
 675     young_gen->eden_space()->check_mangled_unused_area_complete();
 676     young_gen->from_space()->check_mangled_unused_area_complete();
 677     young_gen->to_space()->check_mangled_unused_area_complete();
 678   }
 679 
 680   scavenge_exit.update();
 681 
 682   if (PrintGCTaskTimeStamps) {
 683     tty->print_cr("VM-Thread " INT64_FORMAT " " INT64_FORMAT " " INT64_FORMAT,
 684                   scavenge_entry.ticks(), scavenge_midpoint.ticks(),
 685                   scavenge_exit.ticks());
 686     gc_task_manager()->print_task_time_stamps();
 687   }
 688 
 689 #ifdef TRACESPINNING
 690   ParallelTaskTerminator::print_termination_counts();
 691 #endif
 692 
 693 
 694   _gc_timer.register_gc_end(os::elapsed_counter());
 695 
 696   _gc_tracer.report_gc_end(_gc_timer.gc_end(), _gc_timer.time_partitions());
 697 
 698   return !promotion_failure_occurred;
 699 }
 700 
 701 // This method iterates over all objects in the young generation,
 702 // unforwarding markOops. It then restores any preserved mark oops,
 703 // and clears the _preserved_mark_stack.
 704 void PSScavenge::clean_up_failed_promotion() {
 705   ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
 706   assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity");
 707 
 708   PSYoungGen* young_gen = heap->young_gen();
 709 
 710   {
 711     ResourceMark rm;
 712 
 713     // Unforward all pointers in the young gen.
 714     PSPromotionFailedClosure unforward_closure;




 246 
 247     if (UseParallelOldGC) {
 248       full_gc_done = PSParallelCompact::invoke_no_policy(clear_all_softrefs);
 249     } else {
 250       full_gc_done = PSMarkSweep::invoke_no_policy(clear_all_softrefs);
 251     }
 252   }
 253 
 254   return full_gc_done;
 255 }
 256 
 257 // This method contains no policy. You should probably
 258 // be calling invoke() instead.
 259 bool PSScavenge::invoke_no_policy() {
 260   assert(SafepointSynchronize::is_at_safepoint(), "should be at safepoint");
 261   assert(Thread::current() == (Thread*)VMThread::vm_thread(), "should be in vm thread");
 262 
 263   assert(_preserved_mark_stack.is_empty(), "should be empty");
 264   assert(_preserved_oop_stack.is_empty(), "should be empty");
 265 
 266   _gc_timer.register_gc_start();
 267 
 268   TimeStamp scavenge_entry;
 269   TimeStamp scavenge_midpoint;
 270   TimeStamp scavenge_exit;
 271 
 272   scavenge_entry.update();
 273 
 274   if (GC_locker::check_active_before_gc()) {
 275     return false;
 276   }
 277 
 278   ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
 279   GCCause::Cause gc_cause = heap->gc_cause();
 280   assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity");
 281 
 282   // Check for potential problems.
 283   if (!should_attempt_scavenge()) {
 284     return false;
 285   }
 286 


 674   if (ZapUnusedHeapArea) {
 675     young_gen->eden_space()->check_mangled_unused_area_complete();
 676     young_gen->from_space()->check_mangled_unused_area_complete();
 677     young_gen->to_space()->check_mangled_unused_area_complete();
 678   }
 679 
 680   scavenge_exit.update();
 681 
 682   if (PrintGCTaskTimeStamps) {
 683     tty->print_cr("VM-Thread " INT64_FORMAT " " INT64_FORMAT " " INT64_FORMAT,
 684                   scavenge_entry.ticks(), scavenge_midpoint.ticks(),
 685                   scavenge_exit.ticks());
 686     gc_task_manager()->print_task_time_stamps();
 687   }
 688 
 689 #ifdef TRACESPINNING
 690   ParallelTaskTerminator::print_termination_counts();
 691 #endif
 692 
 693 
 694   _gc_timer.register_gc_end();
 695 
 696   _gc_tracer.report_gc_end(_gc_timer.gc_end(), _gc_timer.time_partitions());
 697 
 698   return !promotion_failure_occurred;
 699 }
 700 
 701 // This method iterates over all objects in the young generation,
 702 // unforwarding markOops. It then restores any preserved mark oops,
 703 // and clears the _preserved_mark_stack.
 704 void PSScavenge::clean_up_failed_promotion() {
 705   ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
 706   assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity");
 707 
 708   PSYoungGen* young_gen = heap->young_gen();
 709 
 710   {
 711     ResourceMark rm;
 712 
 713     // Unforward all pointers in the young gen.
 714     PSPromotionFailedClosure unforward_closure;