src/share/vm/gc/parallel/psMarkSweep.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File hotspot Sdiff src/share/vm/gc/parallel

src/share/vm/gc/parallel/psMarkSweep.cpp

Print this page




  31 #include "gc/parallel/psAdaptiveSizePolicy.hpp"
  32 #include "gc/parallel/psMarkSweep.hpp"
  33 #include "gc/parallel/psMarkSweepDecorator.hpp"
  34 #include "gc/parallel/psOldGen.hpp"
  35 #include "gc/parallel/psScavenge.hpp"
  36 #include "gc/parallel/psYoungGen.hpp"
  37 #include "gc/serial/markSweep.hpp"
  38 #include "gc/shared/gcCause.hpp"
  39 #include "gc/shared/gcHeapSummary.hpp"
  40 #include "gc/shared/gcId.hpp"
  41 #include "gc/shared/gcLocker.inline.hpp"
  42 #include "gc/shared/gcTimer.hpp"
  43 #include "gc/shared/gcTrace.hpp"
  44 #include "gc/shared/gcTraceTime.inline.hpp"
  45 #include "gc/shared/isGCActiveMark.hpp"
  46 #include "gc/shared/referencePolicy.hpp"
  47 #include "gc/shared/referenceProcessor.hpp"
  48 #include "gc/shared/spaceDecorator.hpp"
  49 #include "logging/log.hpp"
  50 #include "oops/oop.inline.hpp"

  51 #include "runtime/biasedLocking.hpp"
  52 #include "runtime/fprofiler.hpp"
  53 #include "runtime/safepoint.hpp"
  54 #include "runtime/vmThread.hpp"
  55 #include "services/management.hpp"
  56 #include "services/memoryService.hpp"
  57 #include "utilities/events.hpp"
  58 #include "utilities/stack.inline.hpp"
  59 
  60 elapsedTimer        PSMarkSweep::_accumulated_time;
  61 jlong               PSMarkSweep::_time_of_last_gc   = 0;
  62 CollectorCounters*  PSMarkSweep::_counters = NULL;
  63 
  64 void PSMarkSweep::initialize() {
  65   MemRegion mr = ParallelScavengeHeap::heap()->reserved_region();
  66   set_ref_processor(new ReferenceProcessor(mr));     // a vanilla ref proc
  67   _counters = new CollectorCounters("PSMarkSweep", 1);
  68 }
  69 
  70 // This method contains all heap specific policy for invoking mark sweep.


 498   ParallelScavengeHeap* heap = ParallelScavengeHeap::heap();
 499 
 500   // Need to clear claim bits before the tracing starts.
 501   ClassLoaderDataGraph::clear_claimed_marks();
 502 
 503   // General strong roots.
 504   {
 505     ParallelScavengeHeap::ParStrongRootsScope psrs;
 506     Universe::oops_do(mark_and_push_closure());
 507     JNIHandles::oops_do(mark_and_push_closure());   // Global (strong) JNI handles
 508     MarkingCodeBlobClosure each_active_code_blob(mark_and_push_closure(), !CodeBlobToOopClosure::FixRelocations);
 509     Threads::oops_do(mark_and_push_closure(), &each_active_code_blob);
 510     ObjectSynchronizer::oops_do(mark_and_push_closure());
 511     FlatProfiler::oops_do(mark_and_push_closure());
 512     Management::oops_do(mark_and_push_closure());
 513     JvmtiExport::oops_do(mark_and_push_closure());
 514     SystemDictionary::always_strong_oops_do(mark_and_push_closure());
 515     ClassLoaderDataGraph::always_strong_cld_do(follow_cld_closure());
 516     // Do not treat nmethods as strong roots for mark/sweep, since we can unload them.
 517     //CodeCache::scavenge_root_nmethods_do(CodeBlobToOopClosure(mark_and_push_closure()));



 518   }
 519 
 520   // Flush marking stack.
 521   follow_stack();
 522 
 523   // Process reference objects found during marking
 524   {
 525     GCTraceTime(Debug, gc, phases) t("Reference Processing", _gc_timer);
 526 
 527     ref_processor()->setup_policy(clear_all_softrefs);
 528     const ReferenceProcessorStats& stats =
 529       ref_processor()->process_discovered_references(
 530         is_alive_closure(), mark_and_push_closure(), follow_stack_closure(), NULL, _gc_timer);
 531     gc_tracer()->report_gc_reference_stats(stats);
 532   }
 533 
 534   // This is the point where the entire marking should have completed.
 535   assert(_marking_stack.is_empty(), "Marking should have completed");
 536 
 537   {


 594   ClassLoaderDataGraph::clear_claimed_marks();
 595 
 596   // General strong roots.
 597   Universe::oops_do(adjust_pointer_closure());
 598   JNIHandles::oops_do(adjust_pointer_closure());   // Global (strong) JNI handles
 599   Threads::oops_do(adjust_pointer_closure(), NULL);
 600   ObjectSynchronizer::oops_do(adjust_pointer_closure());
 601   FlatProfiler::oops_do(adjust_pointer_closure());
 602   Management::oops_do(adjust_pointer_closure());
 603   JvmtiExport::oops_do(adjust_pointer_closure());
 604   SystemDictionary::oops_do(adjust_pointer_closure());
 605   ClassLoaderDataGraph::cld_do(adjust_cld_closure());
 606 
 607   // Now adjust pointers in remaining weak roots.  (All of which should
 608   // have been cleared if they pointed to non-surviving objects.)
 609   // Global (weak) JNI handles
 610   JNIHandles::weak_oops_do(adjust_pointer_closure());
 611 
 612   CodeBlobToOopClosure adjust_from_blobs(adjust_pointer_closure(), CodeBlobToOopClosure::FixRelocations);
 613   CodeCache::blobs_do(&adjust_from_blobs);



 614   StringTable::oops_do(adjust_pointer_closure());
 615   ref_processor()->weak_oops_do(adjust_pointer_closure());
 616   PSScavenge::reference_processor()->weak_oops_do(adjust_pointer_closure());
 617 
 618   adjust_marks();
 619 
 620   young_gen->adjust_pointers();
 621   old_gen->adjust_pointers();
 622 }
 623 
 624 void PSMarkSweep::mark_sweep_phase4() {
 625   EventMark m("4 compact heap");
 626   GCTraceTime(Info, gc, phases) tm("Phase 4: Move objects", _gc_timer);
 627 
 628   // All pointers are now adjusted, move objects accordingly
 629 
 630   ParallelScavengeHeap* heap = ParallelScavengeHeap::heap();
 631   PSYoungGen* young_gen = heap->young_gen();
 632   PSOldGen* old_gen = heap->old_gen();
 633 




  31 #include "gc/parallel/psAdaptiveSizePolicy.hpp"
  32 #include "gc/parallel/psMarkSweep.hpp"
  33 #include "gc/parallel/psMarkSweepDecorator.hpp"
  34 #include "gc/parallel/psOldGen.hpp"
  35 #include "gc/parallel/psScavenge.hpp"
  36 #include "gc/parallel/psYoungGen.hpp"
  37 #include "gc/serial/markSweep.hpp"
  38 #include "gc/shared/gcCause.hpp"
  39 #include "gc/shared/gcHeapSummary.hpp"
  40 #include "gc/shared/gcId.hpp"
  41 #include "gc/shared/gcLocker.inline.hpp"
  42 #include "gc/shared/gcTimer.hpp"
  43 #include "gc/shared/gcTrace.hpp"
  44 #include "gc/shared/gcTraceTime.inline.hpp"
  45 #include "gc/shared/isGCActiveMark.hpp"
  46 #include "gc/shared/referencePolicy.hpp"
  47 #include "gc/shared/referenceProcessor.hpp"
  48 #include "gc/shared/spaceDecorator.hpp"
  49 #include "logging/log.hpp"
  50 #include "oops/oop.inline.hpp"
  51 #include "aot/aotLoader.hpp"
  52 #include "runtime/biasedLocking.hpp"
  53 #include "runtime/fprofiler.hpp"
  54 #include "runtime/safepoint.hpp"
  55 #include "runtime/vmThread.hpp"
  56 #include "services/management.hpp"
  57 #include "services/memoryService.hpp"
  58 #include "utilities/events.hpp"
  59 #include "utilities/stack.inline.hpp"
  60 
  61 elapsedTimer        PSMarkSweep::_accumulated_time;
  62 jlong               PSMarkSweep::_time_of_last_gc   = 0;
  63 CollectorCounters*  PSMarkSweep::_counters = NULL;
  64 
  65 void PSMarkSweep::initialize() {
  66   MemRegion mr = ParallelScavengeHeap::heap()->reserved_region();
  67   set_ref_processor(new ReferenceProcessor(mr));     // a vanilla ref proc
  68   _counters = new CollectorCounters("PSMarkSweep", 1);
  69 }
  70 
  71 // This method contains all heap specific policy for invoking mark sweep.


 499   ParallelScavengeHeap* heap = ParallelScavengeHeap::heap();
 500 
 501   // Need to clear claim bits before the tracing starts.
 502   ClassLoaderDataGraph::clear_claimed_marks();
 503 
 504   // General strong roots.
 505   {
 506     ParallelScavengeHeap::ParStrongRootsScope psrs;
 507     Universe::oops_do(mark_and_push_closure());
 508     JNIHandles::oops_do(mark_and_push_closure());   // Global (strong) JNI handles
 509     MarkingCodeBlobClosure each_active_code_blob(mark_and_push_closure(), !CodeBlobToOopClosure::FixRelocations);
 510     Threads::oops_do(mark_and_push_closure(), &each_active_code_blob);
 511     ObjectSynchronizer::oops_do(mark_and_push_closure());
 512     FlatProfiler::oops_do(mark_and_push_closure());
 513     Management::oops_do(mark_and_push_closure());
 514     JvmtiExport::oops_do(mark_and_push_closure());
 515     SystemDictionary::always_strong_oops_do(mark_and_push_closure());
 516     ClassLoaderDataGraph::always_strong_cld_do(follow_cld_closure());
 517     // Do not treat nmethods as strong roots for mark/sweep, since we can unload them.
 518     //CodeCache::scavenge_root_nmethods_do(CodeBlobToOopClosure(mark_and_push_closure()));
 519     if (UseAOT) {
 520       AOTLoader::oops_do(mark_and_push_closure());
 521     }
 522   }
 523 
 524   // Flush marking stack.
 525   follow_stack();
 526 
 527   // Process reference objects found during marking
 528   {
 529     GCTraceTime(Debug, gc, phases) t("Reference Processing", _gc_timer);
 530 
 531     ref_processor()->setup_policy(clear_all_softrefs);
 532     const ReferenceProcessorStats& stats =
 533       ref_processor()->process_discovered_references(
 534         is_alive_closure(), mark_and_push_closure(), follow_stack_closure(), NULL, _gc_timer);
 535     gc_tracer()->report_gc_reference_stats(stats);
 536   }
 537 
 538   // This is the point where the entire marking should have completed.
 539   assert(_marking_stack.is_empty(), "Marking should have completed");
 540 
 541   {


 598   ClassLoaderDataGraph::clear_claimed_marks();
 599 
 600   // General strong roots.
 601   Universe::oops_do(adjust_pointer_closure());
 602   JNIHandles::oops_do(adjust_pointer_closure());   // Global (strong) JNI handles
 603   Threads::oops_do(adjust_pointer_closure(), NULL);
 604   ObjectSynchronizer::oops_do(adjust_pointer_closure());
 605   FlatProfiler::oops_do(adjust_pointer_closure());
 606   Management::oops_do(adjust_pointer_closure());
 607   JvmtiExport::oops_do(adjust_pointer_closure());
 608   SystemDictionary::oops_do(adjust_pointer_closure());
 609   ClassLoaderDataGraph::cld_do(adjust_cld_closure());
 610 
 611   // Now adjust pointers in remaining weak roots.  (All of which should
 612   // have been cleared if they pointed to non-surviving objects.)
 613   // Global (weak) JNI handles
 614   JNIHandles::weak_oops_do(adjust_pointer_closure());
 615 
 616   CodeBlobToOopClosure adjust_from_blobs(adjust_pointer_closure(), CodeBlobToOopClosure::FixRelocations);
 617   CodeCache::blobs_do(&adjust_from_blobs);
 618   if (UseAOT) {
 619     AOTLoader::oops_do(adjust_pointer_closure());
 620   }
 621   StringTable::oops_do(adjust_pointer_closure());
 622   ref_processor()->weak_oops_do(adjust_pointer_closure());
 623   PSScavenge::reference_processor()->weak_oops_do(adjust_pointer_closure());
 624 
 625   adjust_marks();
 626 
 627   young_gen->adjust_pointers();
 628   old_gen->adjust_pointers();
 629 }
 630 
 631 void PSMarkSweep::mark_sweep_phase4() {
 632   EventMark m("4 compact heap");
 633   GCTraceTime(Info, gc, phases) tm("Phase 4: Move objects", _gc_timer);
 634 
 635   // All pointers are now adjusted, move objects accordingly
 636 
 637   ParallelScavengeHeap* heap = ParallelScavengeHeap::heap();
 638   PSYoungGen* young_gen = heap->young_gen();
 639   PSOldGen* old_gen = heap->old_gen();
 640 


src/share/vm/gc/parallel/psMarkSweep.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File