< prev index next >

src/hotspot/share/gc/g1/g1MarkSweep.cpp

Print this page




  26 #include "classfile/javaClasses.hpp"
  27 #include "classfile/symbolTable.hpp"
  28 #include "classfile/systemDictionary.hpp"
  29 #include "classfile/vmSymbols.hpp"
  30 #include "code/codeCache.hpp"
  31 #include "code/icBuffer.hpp"
  32 #include "gc/g1/g1FullGCScope.hpp"
  33 #include "gc/g1/g1MarkSweep.hpp"
  34 #include "gc/g1/g1RootProcessor.hpp"
  35 #include "gc/g1/g1StringDedup.hpp"
  36 #include "gc/serial/markSweep.inline.hpp"
  37 #include "gc/shared/gcHeapSummary.hpp"
  38 #include "gc/shared/gcLocker.hpp"
  39 #include "gc/shared/gcTimer.hpp"
  40 #include "gc/shared/gcTrace.hpp"
  41 #include "gc/shared/gcTraceTime.inline.hpp"
  42 #include "gc/shared/genCollectedHeap.hpp"
  43 #include "gc/shared/modRefBarrierSet.hpp"
  44 #include "gc/shared/referencePolicy.hpp"
  45 #include "gc/shared/space.hpp"

  46 #include "oops/instanceRefKlass.hpp"
  47 #include "oops/oop.inline.hpp"
  48 #include "prims/jvmtiExport.hpp"
  49 #include "runtime/atomic.hpp"
  50 #include "runtime/biasedLocking.hpp"
  51 #include "runtime/synchronizer.hpp"
  52 #include "runtime/thread.hpp"
  53 #include "runtime/vmThread.hpp"
  54 #include "utilities/copy.hpp"
  55 #include "utilities/events.hpp"
  56 
  57 class HeapRegion;
  58 
  59 void G1MarkSweep::invoke_at_safepoint(ReferenceProcessor* rp,
  60                                       bool clear_all_softrefs) {
  61   assert(SafepointSynchronize::is_at_safepoint(), "must be at a safepoint");
  62   HandleMark hm;  // Discard invalid handles created during gc
  63 
  64 #if defined(COMPILER2) || INCLUDE_JVMCI
  65   DerivedPointerTable::clear();


 164   {
 165     GCTraceTime(Debug, gc, phases) trace("Reference Processing", gc_timer());
 166 
 167     // Process reference objects found during marking
 168     ReferenceProcessor* rp = GenMarkSweep::ref_processor();
 169     assert(rp == g1h->ref_processor_stw(), "Sanity");
 170 
 171     rp->setup_policy(clear_all_softrefs);
 172     ReferenceProcessorPhaseTimes pt(gc_timer(), rp->num_q());
 173 
 174     const ReferenceProcessorStats& stats =
 175         rp->process_discovered_references(&GenMarkSweep::is_alive,
 176                                           &GenMarkSweep::keep_alive,
 177                                           &GenMarkSweep::follow_stack_closure,
 178                                           NULL,
 179                                           &pt);
 180     gc_tracer()->report_gc_reference_stats(stats);
 181     pt.print_all_references();
 182   }
 183 






 184   // This is the point where the entire marking should have completed.
 185   assert(GenMarkSweep::_marking_stack.is_empty(), "Marking should have completed");
 186 
 187   if (ClassUnloading) {
 188     GCTraceTime(Debug, gc, phases) trace("Class Unloading", gc_timer());
 189 
 190     // Unload classes and purge the SystemDictionary.
 191     bool purged_class = SystemDictionary::do_unloading(&GenMarkSweep::is_alive, gc_timer());
 192 
 193     g1h->complete_cleaning(&GenMarkSweep::is_alive, purged_class);
 194   } else {
 195     GCTraceTime(Debug, gc, phases) trace("Cleanup", gc_timer());
 196     g1h->partial_cleaning(&GenMarkSweep::is_alive, true, true, G1StringDedup::is_enabled());
 197   }
 198 
 199   if (VerifyDuringGC) {
 200     HandleMark hm;  // handle scope
 201 #if defined(COMPILER2) || INCLUDE_JVMCI
 202     DerivedPointerTableDeactivate dpt_deact;
 203 #endif


 255 
 256   // Adjust the pointers to reflect the new locations
 257   GCTraceTime(Info, gc, phases) tm("Phase 3: Adjust pointers", gc_timer());
 258 
 259   // Need cleared claim bits for the roots processing
 260   ClassLoaderDataGraph::clear_claimed_marks();
 261 
 262   CodeBlobToOopClosure adjust_code_closure(&GenMarkSweep::adjust_pointer_closure, CodeBlobToOopClosure::FixRelocations);
 263   {
 264     G1RootProcessor root_processor(g1h, 1);
 265     root_processor.process_all_roots(&GenMarkSweep::adjust_pointer_closure,
 266                                      &GenMarkSweep::adjust_cld_closure,
 267                                      &adjust_code_closure);
 268   }
 269 
 270   assert(GenMarkSweep::ref_processor() == g1h->ref_processor_stw(), "Sanity");
 271   g1h->ref_processor_stw()->weak_oops_do(&GenMarkSweep::adjust_pointer_closure);
 272 
 273   // Now adjust pointers in remaining weak roots.  (All of which should
 274   // have been cleared if they pointed to non-surviving objects.)
 275   JNIHandles::weak_oops_do(&GenMarkSweep::adjust_pointer_closure);
 276 
 277   if (G1StringDedup::is_enabled()) {
 278     G1StringDedup::oops_do(&GenMarkSweep::adjust_pointer_closure);
 279   }
 280 
 281   GenMarkSweep::adjust_marks();
 282 
 283   G1AdjustPointersClosure blk;
 284   g1h->heap_region_iterate(&blk);
 285 }
 286 
 287 class G1SpaceCompactClosure: public HeapRegionClosure {
 288 public:
 289   G1SpaceCompactClosure() {}
 290 
 291   bool doHeapRegion(HeapRegion* hr) {
 292     if (hr->is_humongous()) {
 293       if (hr->is_starts_humongous()) {
 294         oop obj = oop(hr->bottom());
 295         if (obj->is_gc_marked()) {




  26 #include "classfile/javaClasses.hpp"
  27 #include "classfile/symbolTable.hpp"
  28 #include "classfile/systemDictionary.hpp"
  29 #include "classfile/vmSymbols.hpp"
  30 #include "code/codeCache.hpp"
  31 #include "code/icBuffer.hpp"
  32 #include "gc/g1/g1FullGCScope.hpp"
  33 #include "gc/g1/g1MarkSweep.hpp"
  34 #include "gc/g1/g1RootProcessor.hpp"
  35 #include "gc/g1/g1StringDedup.hpp"
  36 #include "gc/serial/markSweep.inline.hpp"
  37 #include "gc/shared/gcHeapSummary.hpp"
  38 #include "gc/shared/gcLocker.hpp"
  39 #include "gc/shared/gcTimer.hpp"
  40 #include "gc/shared/gcTrace.hpp"
  41 #include "gc/shared/gcTraceTime.inline.hpp"
  42 #include "gc/shared/genCollectedHeap.hpp"
  43 #include "gc/shared/modRefBarrierSet.hpp"
  44 #include "gc/shared/referencePolicy.hpp"
  45 #include "gc/shared/space.hpp"
  46 #include "gc/shared/weakProcessor.hpp"
  47 #include "oops/instanceRefKlass.hpp"
  48 #include "oops/oop.inline.hpp"
  49 #include "prims/jvmtiExport.hpp"
  50 #include "runtime/atomic.hpp"
  51 #include "runtime/biasedLocking.hpp"
  52 #include "runtime/synchronizer.hpp"
  53 #include "runtime/thread.hpp"
  54 #include "runtime/vmThread.hpp"
  55 #include "utilities/copy.hpp"
  56 #include "utilities/events.hpp"
  57 
  58 class HeapRegion;
  59 
  60 void G1MarkSweep::invoke_at_safepoint(ReferenceProcessor* rp,
  61                                       bool clear_all_softrefs) {
  62   assert(SafepointSynchronize::is_at_safepoint(), "must be at a safepoint");
  63   HandleMark hm;  // Discard invalid handles created during gc
  64 
  65 #if defined(COMPILER2) || INCLUDE_JVMCI
  66   DerivedPointerTable::clear();


 165   {
 166     GCTraceTime(Debug, gc, phases) trace("Reference Processing", gc_timer());
 167 
 168     // Process reference objects found during marking
 169     ReferenceProcessor* rp = GenMarkSweep::ref_processor();
 170     assert(rp == g1h->ref_processor_stw(), "Sanity");
 171 
 172     rp->setup_policy(clear_all_softrefs);
 173     ReferenceProcessorPhaseTimes pt(gc_timer(), rp->num_q());
 174 
 175     const ReferenceProcessorStats& stats =
 176         rp->process_discovered_references(&GenMarkSweep::is_alive,
 177                                           &GenMarkSweep::keep_alive,
 178                                           &GenMarkSweep::follow_stack_closure,
 179                                           NULL,
 180                                           &pt);
 181     gc_tracer()->report_gc_reference_stats(stats);
 182     pt.print_all_references();
 183   }
 184 
 185   {
 186     GCTraceTime(Debug, gc, phases) trace("Weak Processing", gc_timer());
 187     WeakProcessor::weak_oops_do(&GenMarkSweep::is_alive,
 188                                 &GenMarkSweep::keep_alive,
 189                                 &GenMarkSweep::follow_stack_closure);
 190   }
 191   // This is the point where the entire marking should have completed.
 192   assert(GenMarkSweep::_marking_stack.is_empty(), "Marking should have completed");
 193 
 194   if (ClassUnloading) {
 195     GCTraceTime(Debug, gc, phases) trace("Class Unloading", gc_timer());
 196 
 197     // Unload classes and purge the SystemDictionary.
 198     bool purged_class = SystemDictionary::do_unloading(&GenMarkSweep::is_alive, gc_timer());
 199 
 200     g1h->complete_cleaning(&GenMarkSweep::is_alive, purged_class);
 201   } else {
 202     GCTraceTime(Debug, gc, phases) trace("Cleanup", gc_timer());
 203     g1h->partial_cleaning(&GenMarkSweep::is_alive, true, true, G1StringDedup::is_enabled());
 204   }
 205 
 206   if (VerifyDuringGC) {
 207     HandleMark hm;  // handle scope
 208 #if defined(COMPILER2) || INCLUDE_JVMCI
 209     DerivedPointerTableDeactivate dpt_deact;
 210 #endif


 262 
 263   // Adjust the pointers to reflect the new locations
 264   GCTraceTime(Info, gc, phases) tm("Phase 3: Adjust pointers", gc_timer());
 265 
 266   // Need cleared claim bits for the roots processing
 267   ClassLoaderDataGraph::clear_claimed_marks();
 268 
 269   CodeBlobToOopClosure adjust_code_closure(&GenMarkSweep::adjust_pointer_closure, CodeBlobToOopClosure::FixRelocations);
 270   {
 271     G1RootProcessor root_processor(g1h, 1);
 272     root_processor.process_all_roots(&GenMarkSweep::adjust_pointer_closure,
 273                                      &GenMarkSweep::adjust_cld_closure,
 274                                      &adjust_code_closure);
 275   }
 276 
 277   assert(GenMarkSweep::ref_processor() == g1h->ref_processor_stw(), "Sanity");
 278   g1h->ref_processor_stw()->weak_oops_do(&GenMarkSweep::adjust_pointer_closure);
 279 
 280   // Now adjust pointers in remaining weak roots.  (All of which should
 281   // have been cleared if they pointed to non-surviving objects.)
 282   WeakProcessor::oops_do(&GenMarkSweep::adjust_pointer_closure);
 283 
 284   if (G1StringDedup::is_enabled()) {
 285     G1StringDedup::oops_do(&GenMarkSweep::adjust_pointer_closure);
 286   }
 287 
 288   GenMarkSweep::adjust_marks();
 289 
 290   G1AdjustPointersClosure blk;
 291   g1h->heap_region_iterate(&blk);
 292 }
 293 
 294 class G1SpaceCompactClosure: public HeapRegionClosure {
 295 public:
 296   G1SpaceCompactClosure() {}
 297 
 298   bool doHeapRegion(HeapRegion* hr) {
 299     if (hr->is_humongous()) {
 300       if (hr->is_starts_humongous()) {
 301         oop obj = oop(hr->bottom());
 302         if (obj->is_gc_marked()) {


< prev index next >