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

Print this page
rev 2652 : 7085906: Replace the permgen allocated sentinelRef with a self-looped end
Summary: Remove the sentinelRef and let the last Reference in a discovered chain point back to itself.
Reviewed-by: TBD1, TBD2


 499   _preserved_oop_stack.clear(true);
 500   _marking_stack.clear();
 501   _objarray_stack.clear(true);
 502   _revisit_klass_stack.clear(true);
 503   _revisit_mdo_stack.clear(true);
 504 }
 505 
 506 void PSMarkSweep::mark_sweep_phase1(bool clear_all_softrefs) {
 507   // Recursively traverse all live objects and mark them
 508   EventMark m("1 mark object");
 509   TraceTime tm("phase 1", PrintGCDetails && Verbose, true, gclog_or_tty);
 510   trace(" 1");
 511 
 512   ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
 513   assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity");
 514 
 515   // General strong roots.
 516   {
 517     ParallelScavengeHeap::ParStrongRootsScope psrs;
 518     Universe::oops_do(mark_and_push_closure());
 519     ReferenceProcessor::oops_do(mark_and_push_closure());
 520     JNIHandles::oops_do(mark_and_push_closure());   // Global (strong) JNI handles
 521     CodeBlobToOopClosure each_active_code_blob(mark_and_push_closure(), /*do_marking=*/ true);
 522     Threads::oops_do(mark_and_push_closure(), &each_active_code_blob);
 523     ObjectSynchronizer::oops_do(mark_and_push_closure());
 524     FlatProfiler::oops_do(mark_and_push_closure());
 525     Management::oops_do(mark_and_push_closure());
 526     JvmtiExport::oops_do(mark_and_push_closure());
 527     SystemDictionary::always_strong_oops_do(mark_and_push_closure());
 528     // Do not treat nmethods as strong roots for mark/sweep, since we can unload them.
 529     //CodeCache::scavenge_root_nmethods_do(CodeBlobToOopClosure(mark_and_push_closure()));
 530   }
 531 
 532   // Flush marking stack.
 533   follow_stack();
 534 
 535   // Process reference objects found during marking
 536   {
 537     ref_processor()->setup_policy(clear_all_softrefs);
 538     ref_processor()->process_discovered_references(
 539       is_alive_closure(), mark_and_push_closure(), follow_stack_closure(), NULL);


 606   void do_object(oop p) { ShouldNotReachHere(); }
 607   bool do_object_b(oop p) { return true; }
 608 };
 609 static PSAlwaysTrueClosure always_true;
 610 
 611 void PSMarkSweep::mark_sweep_phase3() {
 612   // Adjust the pointers to reflect the new locations
 613   EventMark m("3 adjust pointers");
 614   TraceTime tm("phase 3", PrintGCDetails && Verbose, true, gclog_or_tty);
 615   trace("3");
 616 
 617   ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
 618   assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity");
 619 
 620   PSYoungGen* young_gen = heap->young_gen();
 621   PSOldGen* old_gen = heap->old_gen();
 622   PSPermGen* perm_gen = heap->perm_gen();
 623 
 624   // General strong roots.
 625   Universe::oops_do(adjust_root_pointer_closure());
 626   ReferenceProcessor::oops_do(adjust_root_pointer_closure());
 627   JNIHandles::oops_do(adjust_root_pointer_closure());   // Global (strong) JNI handles
 628   Threads::oops_do(adjust_root_pointer_closure(), NULL);
 629   ObjectSynchronizer::oops_do(adjust_root_pointer_closure());
 630   FlatProfiler::oops_do(adjust_root_pointer_closure());
 631   Management::oops_do(adjust_root_pointer_closure());
 632   JvmtiExport::oops_do(adjust_root_pointer_closure());
 633   // SO_AllClasses
 634   SystemDictionary::oops_do(adjust_root_pointer_closure());
 635   //CodeCache::scavenge_root_nmethods_oops_do(adjust_root_pointer_closure());
 636 
 637   // Now adjust pointers in remaining weak roots.  (All of which should
 638   // have been cleared if they pointed to non-surviving objects.)
 639   // Global (weak) JNI handles
 640   JNIHandles::weak_oops_do(&always_true, adjust_root_pointer_closure());
 641 
 642   CodeCache::oops_do(adjust_pointer_closure());
 643   StringTable::oops_do(adjust_root_pointer_closure());
 644   ref_processor()->weak_oops_do(adjust_root_pointer_closure());
 645   PSScavenge::reference_processor()->weak_oops_do(adjust_root_pointer_closure());
 646 




 499   _preserved_oop_stack.clear(true);
 500   _marking_stack.clear();
 501   _objarray_stack.clear(true);
 502   _revisit_klass_stack.clear(true);
 503   _revisit_mdo_stack.clear(true);
 504 }
 505 
 506 void PSMarkSweep::mark_sweep_phase1(bool clear_all_softrefs) {
 507   // Recursively traverse all live objects and mark them
 508   EventMark m("1 mark object");
 509   TraceTime tm("phase 1", PrintGCDetails && Verbose, true, gclog_or_tty);
 510   trace(" 1");
 511 
 512   ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
 513   assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity");
 514 
 515   // General strong roots.
 516   {
 517     ParallelScavengeHeap::ParStrongRootsScope psrs;
 518     Universe::oops_do(mark_and_push_closure());

 519     JNIHandles::oops_do(mark_and_push_closure());   // Global (strong) JNI handles
 520     CodeBlobToOopClosure each_active_code_blob(mark_and_push_closure(), /*do_marking=*/ true);
 521     Threads::oops_do(mark_and_push_closure(), &each_active_code_blob);
 522     ObjectSynchronizer::oops_do(mark_and_push_closure());
 523     FlatProfiler::oops_do(mark_and_push_closure());
 524     Management::oops_do(mark_and_push_closure());
 525     JvmtiExport::oops_do(mark_and_push_closure());
 526     SystemDictionary::always_strong_oops_do(mark_and_push_closure());
 527     // Do not treat nmethods as strong roots for mark/sweep, since we can unload them.
 528     //CodeCache::scavenge_root_nmethods_do(CodeBlobToOopClosure(mark_and_push_closure()));
 529   }
 530 
 531   // Flush marking stack.
 532   follow_stack();
 533 
 534   // Process reference objects found during marking
 535   {
 536     ref_processor()->setup_policy(clear_all_softrefs);
 537     ref_processor()->process_discovered_references(
 538       is_alive_closure(), mark_and_push_closure(), follow_stack_closure(), NULL);


 605   void do_object(oop p) { ShouldNotReachHere(); }
 606   bool do_object_b(oop p) { return true; }
 607 };
 608 static PSAlwaysTrueClosure always_true;
 609 
 610 void PSMarkSweep::mark_sweep_phase3() {
 611   // Adjust the pointers to reflect the new locations
 612   EventMark m("3 adjust pointers");
 613   TraceTime tm("phase 3", PrintGCDetails && Verbose, true, gclog_or_tty);
 614   trace("3");
 615 
 616   ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
 617   assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity");
 618 
 619   PSYoungGen* young_gen = heap->young_gen();
 620   PSOldGen* old_gen = heap->old_gen();
 621   PSPermGen* perm_gen = heap->perm_gen();
 622 
 623   // General strong roots.
 624   Universe::oops_do(adjust_root_pointer_closure());

 625   JNIHandles::oops_do(adjust_root_pointer_closure());   // Global (strong) JNI handles
 626   Threads::oops_do(adjust_root_pointer_closure(), NULL);
 627   ObjectSynchronizer::oops_do(adjust_root_pointer_closure());
 628   FlatProfiler::oops_do(adjust_root_pointer_closure());
 629   Management::oops_do(adjust_root_pointer_closure());
 630   JvmtiExport::oops_do(adjust_root_pointer_closure());
 631   // SO_AllClasses
 632   SystemDictionary::oops_do(adjust_root_pointer_closure());
 633   //CodeCache::scavenge_root_nmethods_oops_do(adjust_root_pointer_closure());
 634 
 635   // Now adjust pointers in remaining weak roots.  (All of which should
 636   // have been cleared if they pointed to non-surviving objects.)
 637   // Global (weak) JNI handles
 638   JNIHandles::weak_oops_do(&always_true, adjust_root_pointer_closure());
 639 
 640   CodeCache::oops_do(adjust_pointer_closure());
 641   StringTable::oops_do(adjust_root_pointer_closure());
 642   ref_processor()->weak_oops_do(adjust_root_pointer_closure());
 643   PSScavenge::reference_processor()->weak_oops_do(adjust_root_pointer_closure());
 644