< prev index next >

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

Print this page




 203 }
 204 
 205 class G1AdjustPointersClosure: public HeapRegionClosure {
 206  public:
 207   bool doHeapRegion(HeapRegion* r) {
 208     if (r->is_humongous()) {
 209       if (r->is_starts_humongous()) {
 210         // We must adjust the pointers on the single H object.
 211         oop obj = oop(r->bottom());
 212         // point all the oops to the new location
 213         MarkSweep::adjust_pointers(obj);
 214       }
 215     } else if (!r->is_pinned()) {
 216       // This really ought to be "as_CompactibleSpace"...
 217       r->adjust_pointers();
 218     }
 219     return false;
 220   }
 221 };
 222 
 223 class G1AlwaysTrueClosure: public BoolObjectClosure {
 224 public:
 225   bool do_object_b(oop p) { return true; }
 226 };
 227 static G1AlwaysTrueClosure always_true;
 228 
 229 void G1MarkSweep::mark_sweep_phase3() {
 230   G1CollectedHeap* g1h = G1CollectedHeap::heap();
 231 
 232   // Adjust the pointers to reflect the new locations
 233   GCTraceTime(Trace, gc) tm("Phase 3: Adjust pointers", gc_timer());
 234 
 235   // Need cleared claim bits for the roots processing
 236   ClassLoaderDataGraph::clear_claimed_marks();
 237 
 238   CodeBlobToOopClosure adjust_code_closure(&GenMarkSweep::adjust_pointer_closure, CodeBlobToOopClosure::FixRelocations);
 239   {
 240     G1RootProcessor root_processor(g1h, 1);
 241     root_processor.process_all_roots(&GenMarkSweep::adjust_pointer_closure,
 242                                      &GenMarkSweep::adjust_cld_closure,
 243                                      &adjust_code_closure);
 244   }
 245 
 246   assert(GenMarkSweep::ref_processor() == g1h->ref_processor_stw(), "Sanity");
 247   g1h->ref_processor_stw()->weak_oops_do(&GenMarkSweep::adjust_pointer_closure);
 248 
 249   // Now adjust pointers in remaining weak roots.  (All of which should
 250   // have been cleared if they pointed to non-surviving objects.)
 251   JNIHandles::weak_oops_do(&always_true, &GenMarkSweep::adjust_pointer_closure);
 252 
 253   if (G1StringDedup::is_enabled()) {
 254     G1StringDedup::oops_do(&GenMarkSweep::adjust_pointer_closure);
 255   }
 256 
 257   GenMarkSweep::adjust_marks();
 258 
 259   G1AdjustPointersClosure blk;
 260   g1h->heap_region_iterate(&blk);
 261 }
 262 
 263 class G1SpaceCompactClosure: public HeapRegionClosure {
 264 public:
 265   G1SpaceCompactClosure() {}
 266 
 267   bool doHeapRegion(HeapRegion* hr) {
 268     if (hr->is_humongous()) {
 269       if (hr->is_starts_humongous()) {
 270         oop obj = oop(hr->bottom());
 271         if (obj->is_gc_marked()) {




 203 }
 204 
 205 class G1AdjustPointersClosure: public HeapRegionClosure {
 206  public:
 207   bool doHeapRegion(HeapRegion* r) {
 208     if (r->is_humongous()) {
 209       if (r->is_starts_humongous()) {
 210         // We must adjust the pointers on the single H object.
 211         oop obj = oop(r->bottom());
 212         // point all the oops to the new location
 213         MarkSweep::adjust_pointers(obj);
 214       }
 215     } else if (!r->is_pinned()) {
 216       // This really ought to be "as_CompactibleSpace"...
 217       r->adjust_pointers();
 218     }
 219     return false;
 220   }
 221 };
 222 






 223 void G1MarkSweep::mark_sweep_phase3() {
 224   G1CollectedHeap* g1h = G1CollectedHeap::heap();
 225 
 226   // Adjust the pointers to reflect the new locations
 227   GCTraceTime(Trace, gc) tm("Phase 3: Adjust pointers", gc_timer());
 228 
 229   // Need cleared claim bits for the roots processing
 230   ClassLoaderDataGraph::clear_claimed_marks();
 231 
 232   CodeBlobToOopClosure adjust_code_closure(&GenMarkSweep::adjust_pointer_closure, CodeBlobToOopClosure::FixRelocations);
 233   {
 234     G1RootProcessor root_processor(g1h, 1);
 235     root_processor.process_all_roots(&GenMarkSweep::adjust_pointer_closure,
 236                                      &GenMarkSweep::adjust_cld_closure,
 237                                      &adjust_code_closure);
 238   }
 239 
 240   assert(GenMarkSweep::ref_processor() == g1h->ref_processor_stw(), "Sanity");
 241   g1h->ref_processor_stw()->weak_oops_do(&GenMarkSweep::adjust_pointer_closure);
 242 
 243   // Now adjust pointers in remaining weak roots.  (All of which should
 244   // have been cleared if they pointed to non-surviving objects.)
 245   JNIHandles::weak_oops_do(&GenMarkSweep::adjust_pointer_closure);
 246 
 247   if (G1StringDedup::is_enabled()) {
 248     G1StringDedup::oops_do(&GenMarkSweep::adjust_pointer_closure);
 249   }
 250 
 251   GenMarkSweep::adjust_marks();
 252 
 253   G1AdjustPointersClosure blk;
 254   g1h->heap_region_iterate(&blk);
 255 }
 256 
 257 class G1SpaceCompactClosure: public HeapRegionClosure {
 258 public:
 259   G1SpaceCompactClosure() {}
 260 
 261   bool doHeapRegion(HeapRegion* hr) {
 262     if (hr->is_humongous()) {
 263       if (hr->is_starts_humongous()) {
 264         oop obj = oop(hr->bottom());
 265         if (obj->is_gc_marked()) {


< prev index next >