< prev index next >

src/share/vm/gc_implementation/g1/g1MarkSweep.cpp

Print this page




  35 #include "gc_implementation/g1/g1StringDedup.hpp"
  36 #include "gc_implementation/shared/gcHeapSummary.hpp"
  37 #include "gc_implementation/shared/gcTimer.hpp"
  38 #include "gc_implementation/shared/gcTrace.hpp"
  39 #include "gc_implementation/shared/gcTraceTime.hpp"
  40 #include "memory/gcLocker.hpp"
  41 #include "memory/genCollectedHeap.hpp"
  42 #include "memory/modRefBarrierSet.hpp"
  43 #include "memory/referencePolicy.hpp"
  44 #include "memory/space.hpp"
  45 #include "oops/instanceRefKlass.hpp"
  46 #include "oops/oop.inline.hpp"
  47 #include "prims/jvmtiExport.hpp"
  48 #include "runtime/biasedLocking.hpp"
  49 #include "runtime/fprofiler.hpp"
  50 #include "runtime/synchronizer.hpp"
  51 #include "runtime/thread.hpp"
  52 #include "runtime/vmThread.hpp"
  53 #include "utilities/copy.hpp"
  54 #include "utilities/events.hpp"



  55 
  56 class HeapRegion;
  57 
  58 void G1MarkSweep::invoke_at_safepoint(ReferenceProcessor* rp,
  59                                       bool clear_all_softrefs) {
  60   assert(SafepointSynchronize::is_at_safepoint(), "must be at a safepoint");
  61 
  62   SharedHeap* sh = SharedHeap::heap();
  63 #ifdef ASSERT
  64   if (sh->collector_policy()->should_clear_all_soft_refs()) {
  65     assert(clear_all_softrefs, "Policy should have been checked earler");
  66   }
  67 #endif
  68   // hook up weak ref data so it can be used during Mark-Sweep
  69   assert(GenMarkSweep::ref_processor() == NULL, "no stomping");
  70   assert(rp != NULL, "should be non-NULL");
  71   assert(rp == G1CollectedHeap::heap()->ref_processor_stw(), "Precondition");
  72 
  73   GenMarkSweep::_ref_processor = rp;
  74   rp->setup_policy(clear_all_softrefs);


 244   GCTraceTime tm("phase 3", G1Log::fine() && Verbose, true, gc_timer(), gc_tracer()->gc_id());
 245   GenMarkSweep::trace("3");
 246 
 247   // Need cleared claim bits for the roots processing
 248   ClassLoaderDataGraph::clear_claimed_marks();
 249 
 250   CodeBlobToOopClosure adjust_code_closure(&GenMarkSweep::adjust_pointer_closure, CodeBlobToOopClosure::FixRelocations);
 251   {
 252     G1RootProcessor root_processor(g1h);
 253     root_processor.process_all_roots(&GenMarkSweep::adjust_pointer_closure,
 254                                      &GenMarkSweep::adjust_cld_closure,
 255                                      &adjust_code_closure);
 256   }
 257 
 258   assert(GenMarkSweep::ref_processor() == g1h->ref_processor_stw(), "Sanity");
 259   g1h->ref_processor_stw()->weak_oops_do(&GenMarkSweep::adjust_pointer_closure);
 260 
 261   // Now adjust pointers in remaining weak roots.  (All of which should
 262   // have been cleared if they pointed to non-surviving objects.)
 263   JNIHandles::weak_oops_do(&GenMarkSweep::adjust_pointer_closure);

 264 
 265   if (G1StringDedup::is_enabled()) {
 266     G1StringDedup::oops_do(&GenMarkSweep::adjust_pointer_closure);
 267   }
 268 
 269   GenMarkSweep::adjust_marks();
 270 
 271   G1AdjustPointersClosure blk;
 272   g1h->heap_region_iterate(&blk);
 273 }
 274 
 275 class G1SpaceCompactClosure: public HeapRegionClosure {
 276 public:
 277   G1SpaceCompactClosure() {}
 278 
 279   bool doHeapRegion(HeapRegion* hr) {
 280     if (hr->isHumongous()) {
 281       if (hr->startsHumongous()) {
 282         oop obj = oop(hr->bottom());
 283         if (obj->is_gc_marked()) {




  35 #include "gc_implementation/g1/g1StringDedup.hpp"
  36 #include "gc_implementation/shared/gcHeapSummary.hpp"
  37 #include "gc_implementation/shared/gcTimer.hpp"
  38 #include "gc_implementation/shared/gcTrace.hpp"
  39 #include "gc_implementation/shared/gcTraceTime.hpp"
  40 #include "memory/gcLocker.hpp"
  41 #include "memory/genCollectedHeap.hpp"
  42 #include "memory/modRefBarrierSet.hpp"
  43 #include "memory/referencePolicy.hpp"
  44 #include "memory/space.hpp"
  45 #include "oops/instanceRefKlass.hpp"
  46 #include "oops/oop.inline.hpp"
  47 #include "prims/jvmtiExport.hpp"
  48 #include "runtime/biasedLocking.hpp"
  49 #include "runtime/fprofiler.hpp"
  50 #include "runtime/synchronizer.hpp"
  51 #include "runtime/thread.hpp"
  52 #include "runtime/vmThread.hpp"
  53 #include "utilities/copy.hpp"
  54 #include "utilities/events.hpp"
  55 #if INCLUDE_JFR
  56 #include "jfr/jfr.hpp"
  57 #endif // INCLUDE_JFR
  58 
  59 class HeapRegion;
  60 
  61 void G1MarkSweep::invoke_at_safepoint(ReferenceProcessor* rp,
  62                                       bool clear_all_softrefs) {
  63   assert(SafepointSynchronize::is_at_safepoint(), "must be at a safepoint");
  64 
  65   SharedHeap* sh = SharedHeap::heap();
  66 #ifdef ASSERT
  67   if (sh->collector_policy()->should_clear_all_soft_refs()) {
  68     assert(clear_all_softrefs, "Policy should have been checked earler");
  69   }
  70 #endif
  71   // hook up weak ref data so it can be used during Mark-Sweep
  72   assert(GenMarkSweep::ref_processor() == NULL, "no stomping");
  73   assert(rp != NULL, "should be non-NULL");
  74   assert(rp == G1CollectedHeap::heap()->ref_processor_stw(), "Precondition");
  75 
  76   GenMarkSweep::_ref_processor = rp;
  77   rp->setup_policy(clear_all_softrefs);


 247   GCTraceTime tm("phase 3", G1Log::fine() && Verbose, true, gc_timer(), gc_tracer()->gc_id());
 248   GenMarkSweep::trace("3");
 249 
 250   // Need cleared claim bits for the roots processing
 251   ClassLoaderDataGraph::clear_claimed_marks();
 252 
 253   CodeBlobToOopClosure adjust_code_closure(&GenMarkSweep::adjust_pointer_closure, CodeBlobToOopClosure::FixRelocations);
 254   {
 255     G1RootProcessor root_processor(g1h);
 256     root_processor.process_all_roots(&GenMarkSweep::adjust_pointer_closure,
 257                                      &GenMarkSweep::adjust_cld_closure,
 258                                      &adjust_code_closure);
 259   }
 260 
 261   assert(GenMarkSweep::ref_processor() == g1h->ref_processor_stw(), "Sanity");
 262   g1h->ref_processor_stw()->weak_oops_do(&GenMarkSweep::adjust_pointer_closure);
 263 
 264   // Now adjust pointers in remaining weak roots.  (All of which should
 265   // have been cleared if they pointed to non-surviving objects.)
 266   JNIHandles::weak_oops_do(&GenMarkSweep::adjust_pointer_closure);
 267   JFR_ONLY(Jfr::weak_oops_do(&GenMarkSweep::adjust_pointer_closure));
 268 
 269   if (G1StringDedup::is_enabled()) {
 270     G1StringDedup::oops_do(&GenMarkSweep::adjust_pointer_closure);
 271   }
 272 
 273   GenMarkSweep::adjust_marks();
 274 
 275   G1AdjustPointersClosure blk;
 276   g1h->heap_region_iterate(&blk);
 277 }
 278 
 279 class G1SpaceCompactClosure: public HeapRegionClosure {
 280 public:
 281   G1SpaceCompactClosure() {}
 282 
 283   bool doHeapRegion(HeapRegion* hr) {
 284     if (hr->isHumongous()) {
 285       if (hr->startsHumongous()) {
 286         oop obj = oop(hr->bottom());
 287         if (obj->is_gc_marked()) {


< prev index next >