hotspot/src/share/vm/gc/g1/g1MarkSweep.cpp
changeset 31346 a70d45c06136
parent 30868 c1b24f26deed
child 32589 f86fb16fcab0
equal deleted inserted replaced
31345:1bba15125d8d 31346:a70d45c06136
    55 #include "utilities/copy.hpp"
    55 #include "utilities/copy.hpp"
    56 #include "utilities/events.hpp"
    56 #include "utilities/events.hpp"
    57 
    57 
    58 class HeapRegion;
    58 class HeapRegion;
    59 
    59 
       
    60 bool G1MarkSweep::_archive_check_enabled = false;
       
    61 G1ArchiveRegionMap G1MarkSweep::_archive_region_map;
       
    62 
    60 void G1MarkSweep::invoke_at_safepoint(ReferenceProcessor* rp,
    63 void G1MarkSweep::invoke_at_safepoint(ReferenceProcessor* rp,
    61                                       bool clear_all_softrefs) {
    64                                       bool clear_all_softrefs) {
    62   assert(SafepointSynchronize::is_at_safepoint(), "must be at a safepoint");
    65   assert(SafepointSynchronize::is_at_safepoint(), "must be at a safepoint");
    63 
    66 
    64 #ifdef ASSERT
    67 #ifdef ASSERT
   210         // We must adjust the pointers on the single H object.
   213         // We must adjust the pointers on the single H object.
   211         oop obj = oop(r->bottom());
   214         oop obj = oop(r->bottom());
   212         // point all the oops to the new location
   215         // point all the oops to the new location
   213         MarkSweep::adjust_pointers(obj);
   216         MarkSweep::adjust_pointers(obj);
   214       }
   217       }
   215     } else {
   218     } else if (!r->is_pinned()) {
   216       // This really ought to be "as_CompactibleSpace"...
   219       // This really ought to be "as_CompactibleSpace"...
   217       r->adjust_pointers();
   220       r->adjust_pointers();
   218     }
   221     }
   219     return false;
   222     return false;
   220   }
   223   }
   273         } else {
   276         } else {
   274           assert(hr->is_empty(), "Should have been cleared in phase 2.");
   277           assert(hr->is_empty(), "Should have been cleared in phase 2.");
   275         }
   278         }
   276         hr->reset_during_compaction();
   279         hr->reset_during_compaction();
   277       }
   280       }
   278     } else {
   281     } else if (!hr->is_pinned()) {
   279       hr->compact();
   282       hr->compact();
   280     }
   283     }
   281     return false;
   284     return false;
   282   }
   285   }
   283 };
   286 };
   294   GCTraceTime tm("phase 4", G1Log::fine() && Verbose, true, gc_timer(), gc_tracer()->gc_id());
   297   GCTraceTime tm("phase 4", G1Log::fine() && Verbose, true, gc_timer(), gc_tracer()->gc_id());
   295 
   298 
   296   G1SpaceCompactClosure blk;
   299   G1SpaceCompactClosure blk;
   297   g1h->heap_region_iterate(&blk);
   300   g1h->heap_region_iterate(&blk);
   298 
   301 
       
   302 }
       
   303 
       
   304 void G1MarkSweep::enable_archive_object_check() {
       
   305   assert(!_archive_check_enabled, "archive range check already enabled");
       
   306   _archive_check_enabled = true;
       
   307   size_t length = Universe::heap()->max_capacity();
       
   308   _archive_region_map.initialize((HeapWord*)Universe::heap()->base(),
       
   309                                  (HeapWord*)Universe::heap()->base() + length,
       
   310                                  HeapRegion::GrainBytes);
       
   311 }
       
   312 
       
   313 void G1MarkSweep::mark_range_archive(MemRegion range) {
       
   314   assert(_archive_check_enabled, "archive range check not enabled");
       
   315   _archive_region_map.set_by_address(range, true);
       
   316 }
       
   317 
       
   318 bool G1MarkSweep::in_archive_range(oop object) {
       
   319   // This is the out-of-line part of is_archive_object test, done separately
       
   320   // to avoid additional performance impact when the check is not enabled.
       
   321   return _archive_region_map.get_by_address((HeapWord*)object);
   299 }
   322 }
   300 
   323 
   301 void G1MarkSweep::prepare_compaction_work(G1PrepareCompactClosure* blk) {
   324 void G1MarkSweep::prepare_compaction_work(G1PrepareCompactClosure* blk) {
   302   G1CollectedHeap* g1h = G1CollectedHeap::heap();
   325   G1CollectedHeap* g1h = G1CollectedHeap::heap();
   303   g1h->heap_region_iterate(blk);
   326   g1h->heap_region_iterate(blk);
   355         free_humongous_region(hr);
   378         free_humongous_region(hr);
   356       }
   379       }
   357     } else {
   380     } else {
   358       assert(hr->is_continues_humongous(), "Invalid humongous.");
   381       assert(hr->is_continues_humongous(), "Invalid humongous.");
   359     }
   382     }
   360   } else {
   383   } else if (!hr->is_pinned()) {
   361     prepare_for_compaction(hr, hr->end());
   384     prepare_for_compaction(hr, hr->end());
   362   }
   385   }
   363   return false;
   386   return false;
   364 }
   387 }