< prev index next >

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

Print this page

 23  */
 24 
 25 #include "precompiled.hpp"
 26 #include "classfile/classLoaderData.hpp"
 27 #include "classfile/classLoaderDataGraph.hpp"
 28 #include "gc/g1/g1CollectedHeap.hpp"
 29 #include "gc/g1/g1ConcurrentMarkBitMap.inline.hpp"
 30 #include "gc/g1/g1FullCollector.inline.hpp"
 31 #include "gc/g1/g1FullGCAdjustTask.hpp"
 32 #include "gc/g1/g1FullGCCompactionPoint.hpp"
 33 #include "gc/g1/g1FullGCMarker.hpp"
 34 #include "gc/g1/g1FullGCOopClosures.inline.hpp"
 35 #include "gc/g1/heapRegion.inline.hpp"
 36 #include "gc/shared/gcTraceTime.inline.hpp"
 37 #include "gc/shared/referenceProcessor.hpp"
 38 #include "gc/shared/weakProcessor.inline.hpp"
 39 #include "logging/log.hpp"
 40 #include "memory/iterator.inline.hpp"
 41 #include "runtime/atomic.hpp"
 42 

 43 class G1AdjustLiveClosure : public StackObj {
 44   G1AdjustClosure* _adjust_closure;
 45 public:
 46   G1AdjustLiveClosure(G1AdjustClosure* cl) :
 47     _adjust_closure(cl) { }
 48 
 49   size_t apply(oop object) {
 50     return object->oop_iterate_size(_adjust_closure);
 51   }
 52 };
 53 
 54 class G1AdjustRegionClosure : public HeapRegionClosure {
 55   G1FullCollector* _collector;
 56   G1CMBitMap* _bitmap;
 57   uint _worker_id;
 58  public:
 59   G1AdjustRegionClosure(G1FullCollector* collector, uint worker_id) :
 60     _collector(collector),
 61     _bitmap(collector->mark_bitmap()),
 62     _worker_id(worker_id) { }
 63 
 64   bool do_heap_region(HeapRegion* r) {
 65     G1AdjustClosure cl(_collector);










 66     if (r->is_humongous()) {
 67       // Special handling for humongous regions to get somewhat better
 68       // work distribution.
 69       oop obj = cast_to_oop(r->humongous_start_region()->bottom());
 70       obj->oop_iterate(&cl, MemRegion(r->bottom(), r->top()));
 71     } else if (!r->is_free()) {
 72       // Free regions do not contain objects to iterate. So skip them.
 73       G1AdjustLiveClosure adjust(&cl);
 74       r->apply_to_marked_objects(_bitmap, &adjust);
 75     }
 76     return false;
 77   }
 78 };
 79 
 80 G1FullGCAdjustTask::G1FullGCAdjustTask(G1FullCollector* collector) :
 81     G1FullGCTask("G1 Adjust", collector),
 82     _root_processor(G1CollectedHeap::heap(), collector->workers()),
 83     _weak_proc_task(collector->workers()),
 84     _hrclaimer(collector->workers()),
 85     _adjust(collector) {
 86   ClassLoaderDataGraph::verify_claimed_marks_cleared(ClassLoaderData::_claim_stw_fullgc_adjust);
 87 }
 88 
 89 void G1FullGCAdjustTask::work(uint worker_id) {

 90   Ticks start = Ticks::now();
 91   ResourceMark rm;
 92 
 93   // Adjust preserved marks first since they are not balanced.
 94   G1FullGCMarker* marker = collector()->marker(worker_id);
 95   marker->preserved_stack()->adjust_during_full_gc();
 96 

 97   {
 98     // Adjust the weak roots.
 99     AlwaysTrueClosure always_alive;
100     _weak_proc_task.work(worker_id, &always_alive, &_adjust);
101   }
102 
103   CLDToOopClosure adjust_cld(&_adjust, ClassLoaderData::_claim_stw_fullgc_adjust);
104   CodeBlobToOopClosure adjust_code(&_adjust, CodeBlobToOopClosure::FixRelocations);
105   _root_processor.process_all_roots(&_adjust, &adjust_cld, &adjust_code);
106 
107   // Now adjust pointers region by region
108   G1AdjustRegionClosure blk(collector(), worker_id);
109   G1CollectedHeap::heap()->heap_region_par_iterate_from_worker_offset(&blk, &_hrclaimer, worker_id);
110   log_task("Adjust task", worker_id, start);
111 }









 23  */
 24 
 25 #include "precompiled.hpp"
 26 #include "classfile/classLoaderData.hpp"
 27 #include "classfile/classLoaderDataGraph.hpp"
 28 #include "gc/g1/g1CollectedHeap.hpp"
 29 #include "gc/g1/g1ConcurrentMarkBitMap.inline.hpp"
 30 #include "gc/g1/g1FullCollector.inline.hpp"
 31 #include "gc/g1/g1FullGCAdjustTask.hpp"
 32 #include "gc/g1/g1FullGCCompactionPoint.hpp"
 33 #include "gc/g1/g1FullGCMarker.hpp"
 34 #include "gc/g1/g1FullGCOopClosures.inline.hpp"
 35 #include "gc/g1/heapRegion.inline.hpp"
 36 #include "gc/shared/gcTraceTime.inline.hpp"
 37 #include "gc/shared/referenceProcessor.hpp"
 38 #include "gc/shared/weakProcessor.inline.hpp"
 39 #include "logging/log.hpp"
 40 #include "memory/iterator.inline.hpp"
 41 #include "runtime/atomic.hpp"
 42 
 43 template <bool ALT_FWD>
 44 class G1AdjustLiveClosure : public StackObj {
 45   G1AdjustClosure<ALT_FWD>* _adjust_closure;
 46 public:
 47   G1AdjustLiveClosure(G1AdjustClosure<ALT_FWD>* cl) :
 48     _adjust_closure(cl) { }
 49 
 50   size_t apply(oop object) {
 51     return object->oop_iterate_size(_adjust_closure);
 52   }
 53 };
 54 
 55 class G1AdjustRegionClosure : public HeapRegionClosure {
 56   G1FullCollector* _collector;
 57   G1CMBitMap* _bitmap;
 58   uint _worker_id;
 59  public:
 60   G1AdjustRegionClosure(G1FullCollector* collector, uint worker_id) :
 61     _collector(collector),
 62     _bitmap(collector->mark_bitmap()),
 63     _worker_id(worker_id) { }
 64 
 65   bool do_heap_region(HeapRegion* r) {
 66     if (UseAltGCForwarding) {
 67       return do_heap_region_impl<true>(r);
 68     } else {
 69       return do_heap_region_impl<false>(r);
 70     }
 71   }
 72 
 73 private:
 74   template <bool ALT_FWD>
 75   bool do_heap_region_impl(HeapRegion* r) {
 76     G1AdjustClosure<ALT_FWD> cl(_collector);
 77     if (r->is_humongous()) {
 78       // Special handling for humongous regions to get somewhat better
 79       // work distribution.
 80       oop obj = cast_to_oop(r->humongous_start_region()->bottom());
 81       obj->oop_iterate(&cl, MemRegion(r->bottom(), r->top()));
 82     } else if (!r->is_free()) {
 83       // Free regions do not contain objects to iterate. So skip them.
 84       G1AdjustLiveClosure<ALT_FWD> adjust(&cl);
 85       r->apply_to_marked_objects(_bitmap, &adjust);
 86     }
 87     return false;
 88   }
 89 };
 90 
 91 G1FullGCAdjustTask::G1FullGCAdjustTask(G1FullCollector* collector) :
 92     G1FullGCTask("G1 Adjust", collector),
 93     _root_processor(G1CollectedHeap::heap(), collector->workers()),
 94     _weak_proc_task(collector->workers()),
 95     _hrclaimer(collector->workers()) {

 96   ClassLoaderDataGraph::verify_claimed_marks_cleared(ClassLoaderData::_claim_stw_fullgc_adjust);
 97 }
 98 
 99 template <bool ALT_FWD>
100 void G1FullGCAdjustTask::work_impl(uint worker_id) {
101   Ticks start = Ticks::now();
102   ResourceMark rm;
103 
104   // Adjust preserved marks first since they are not balanced.
105   G1FullGCMarker* marker = collector()->marker(worker_id);
106   marker->preserved_stack()->adjust_during_full_gc();
107 
108   G1AdjustClosure<ALT_FWD> adjust(collector());
109   {
110     // Adjust the weak roots.
111     AlwaysTrueClosure always_alive;
112     _weak_proc_task.work(worker_id, &always_alive, &adjust);
113   }
114 
115   CLDToOopClosure adjust_cld(&adjust, ClassLoaderData::_claim_stw_fullgc_adjust);
116   CodeBlobToOopClosure adjust_code(&adjust, CodeBlobToOopClosure::FixRelocations);
117   _root_processor.process_all_roots(&adjust, &adjust_cld, &adjust_code);
118 
119   // Now adjust pointers region by region
120   G1AdjustRegionClosure blk(collector(), worker_id);
121   G1CollectedHeap::heap()->heap_region_par_iterate_from_worker_offset(&blk, &_hrclaimer, worker_id);
122   log_task("Adjust task", worker_id, start);
123 }
124 
125 void G1FullGCAdjustTask::work(uint worker_id) {
126   if (UseAltGCForwarding) {
127     work_impl<true>(worker_id);
128   } else {
129     work_impl<false>(worker_id);
130   }
131 }
< prev index next >