src/hotspot/share/gc/serial/genMarkSweep.cpp
Index Unified diffs Context diffs Sdiffs Frames Patch New Old Previous File Next File open Sdiff src/hotspot/share/gc/serial

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

Print this page




  29 #include "classfile/symbolTable.hpp"
  30 #include "classfile/systemDictionary.hpp"
  31 #include "classfile/vmSymbols.hpp"
  32 #include "code/codeCache.hpp"
  33 #include "code/icBuffer.hpp"
  34 #include "gc/serial/genMarkSweep.hpp"
  35 #include "gc/shared/collectedHeap.inline.hpp"
  36 #include "gc/shared/gcHeapSummary.hpp"
  37 #include "gc/shared/gcTimer.hpp"
  38 #include "gc/shared/gcTrace.hpp"
  39 #include "gc/shared/gcTraceTime.inline.hpp"
  40 #include "gc/shared/genCollectedHeap.hpp"
  41 #include "gc/shared/generation.hpp"
  42 #include "gc/shared/genOopClosures.inline.hpp"
  43 #include "gc/shared/modRefBarrierSet.hpp"
  44 #include "gc/shared/referencePolicy.hpp"
  45 #include "gc/shared/referenceProcessorPhaseTimes.hpp"
  46 #include "gc/shared/space.hpp"
  47 #include "gc/shared/strongRootsScope.hpp"
  48 #include "gc/shared/weakProcessor.hpp"



  49 #include "oops/instanceRefKlass.hpp"
  50 #include "oops/oop.inline.hpp"
  51 #include "prims/jvmtiExport.hpp"
  52 #include "runtime/handles.inline.hpp"
  53 #include "runtime/synchronizer.hpp"
  54 #include "runtime/thread.inline.hpp"
  55 #include "runtime/vmThread.hpp"
  56 #include "utilities/copy.hpp"
  57 #include "utilities/events.hpp"
  58 #include "utilities/stack.inline.hpp"
  59 
  60 void GenMarkSweep::invoke_at_safepoint(ReferenceProcessor* rp, bool clear_all_softrefs) {
  61   assert(SafepointSynchronize::is_at_safepoint(), "must be at a safepoint");
  62 
  63   GenCollectedHeap* gch = GenCollectedHeap::heap();
  64 #ifdef ASSERT
  65   if (gch->soft_ref_policy()->should_clear_all_soft_refs()) {
  66     assert(clear_all_softrefs, "Policy should have been checked earlier");
  67   }
  68 #endif


 216 
 217   // This is the point where the entire marking should have completed.
 218   assert(_marking_stack.is_empty(), "Marking should have completed");
 219 
 220   {
 221     GCTraceTime(Debug, gc, phases) tm_m("Weak Processing", gc_timer());
 222     WeakProcessor::weak_oops_do(&is_alive, &do_nothing_cl);
 223   }
 224 
 225   {
 226     GCTraceTime(Debug, gc, phases) tm_m("Class Unloading", gc_timer());
 227 
 228     // Unload classes and purge the SystemDictionary.
 229     bool purged_class = SystemDictionary::do_unloading(gc_timer());
 230 
 231     // Unload nmethods.
 232     CodeCache::do_unloading(&is_alive, purged_class);
 233 
 234     // Prune dead klasses from subklass/sibling/implementor lists.
 235     Klass::clean_weak_klass_links(purged_class);





 236   }
 237 
 238   gc_tracer()->report_object_count_after_gc(&is_alive);
 239 }
 240 
 241 
 242 void GenMarkSweep::mark_sweep_phase2() {
 243   // Now all live objects are marked, compute the new object addresses.
 244 
 245   // It is imperative that we traverse perm_gen LAST. If dead space is
 246   // allowed a range of dead object may get overwritten by a dead int
 247   // array. If perm_gen is not traversed last a Klass* may get
 248   // overwritten. This is fine since it is dead, but if the class has dead
 249   // instances we have to skip them, and in order to find their size we
 250   // need the Klass*!
 251   //
 252   // It is not required that we traverse spaces in the same order in
 253   // phase2, phase3 and phase4, but the ValidateMarkSweep live oops
 254   // tracking expects us to do so. See comment under phase4.
 255 




  29 #include "classfile/symbolTable.hpp"
  30 #include "classfile/systemDictionary.hpp"
  31 #include "classfile/vmSymbols.hpp"
  32 #include "code/codeCache.hpp"
  33 #include "code/icBuffer.hpp"
  34 #include "gc/serial/genMarkSweep.hpp"
  35 #include "gc/shared/collectedHeap.inline.hpp"
  36 #include "gc/shared/gcHeapSummary.hpp"
  37 #include "gc/shared/gcTimer.hpp"
  38 #include "gc/shared/gcTrace.hpp"
  39 #include "gc/shared/gcTraceTime.inline.hpp"
  40 #include "gc/shared/genCollectedHeap.hpp"
  41 #include "gc/shared/generation.hpp"
  42 #include "gc/shared/genOopClosures.inline.hpp"
  43 #include "gc/shared/modRefBarrierSet.hpp"
  44 #include "gc/shared/referencePolicy.hpp"
  45 #include "gc/shared/referenceProcessorPhaseTimes.hpp"
  46 #include "gc/shared/space.hpp"
  47 #include "gc/shared/strongRootsScope.hpp"
  48 #include "gc/shared/weakProcessor.hpp"
  49 #if INCLUDE_JVMCI
  50 #include "jvmci/jvmci.hpp"
  51 #endif
  52 #include "oops/instanceRefKlass.hpp"
  53 #include "oops/oop.inline.hpp"
  54 #include "prims/jvmtiExport.hpp"
  55 #include "runtime/handles.inline.hpp"
  56 #include "runtime/synchronizer.hpp"
  57 #include "runtime/thread.inline.hpp"
  58 #include "runtime/vmThread.hpp"
  59 #include "utilities/copy.hpp"
  60 #include "utilities/events.hpp"
  61 #include "utilities/stack.inline.hpp"
  62 
  63 void GenMarkSweep::invoke_at_safepoint(ReferenceProcessor* rp, bool clear_all_softrefs) {
  64   assert(SafepointSynchronize::is_at_safepoint(), "must be at a safepoint");
  65 
  66   GenCollectedHeap* gch = GenCollectedHeap::heap();
  67 #ifdef ASSERT
  68   if (gch->soft_ref_policy()->should_clear_all_soft_refs()) {
  69     assert(clear_all_softrefs, "Policy should have been checked earlier");
  70   }
  71 #endif


 219 
 220   // This is the point where the entire marking should have completed.
 221   assert(_marking_stack.is_empty(), "Marking should have completed");
 222 
 223   {
 224     GCTraceTime(Debug, gc, phases) tm_m("Weak Processing", gc_timer());
 225     WeakProcessor::weak_oops_do(&is_alive, &do_nothing_cl);
 226   }
 227 
 228   {
 229     GCTraceTime(Debug, gc, phases) tm_m("Class Unloading", gc_timer());
 230 
 231     // Unload classes and purge the SystemDictionary.
 232     bool purged_class = SystemDictionary::do_unloading(gc_timer());
 233 
 234     // Unload nmethods.
 235     CodeCache::do_unloading(&is_alive, purged_class);
 236 
 237     // Prune dead klasses from subklass/sibling/implementor lists.
 238     Klass::clean_weak_klass_links(purged_class);
 239 
 240 #if INCLUDE_JVMCI
 241     // Clean JVMCI metadata handles.
 242     JVMCI::do_unloading(&is_alive, purged_class);
 243 #endif
 244   }
 245 
 246   gc_tracer()->report_object_count_after_gc(&is_alive);
 247 }
 248 
 249 
 250 void GenMarkSweep::mark_sweep_phase2() {
 251   // Now all live objects are marked, compute the new object addresses.
 252 
 253   // It is imperative that we traverse perm_gen LAST. If dead space is
 254   // allowed a range of dead object may get overwritten by a dead int
 255   // array. If perm_gen is not traversed last a Klass* may get
 256   // overwritten. This is fine since it is dead, but if the class has dead
 257   // instances we have to skip them, and in order to find their size we
 258   // need the Klass*!
 259   //
 260   // It is not required that we traverse spaces in the same order in
 261   // phase2, phase3 and phase4, but the ValidateMarkSweep live oops
 262   // tracking expects us to do so. See comment under phase4.
 263 


src/hotspot/share/gc/serial/genMarkSweep.cpp
Index Unified diffs Context diffs Sdiffs Frames Patch New Old Previous File Next File