26 #define SHARE_VM_GC_G1_G1OOPCLOSURES_HPP 27 28 #include "gc/g1/g1InCSetState.hpp" 29 #include "memory/iterator.hpp" 30 #include "oops/markOop.hpp" 31 32 class HeapRegion; 33 class G1CollectedHeap; 34 class G1RemSet; 35 class G1ConcurrentMark; 36 class DirtyCardToOopClosure; 37 class G1CMBitMap; 38 class G1ParScanThreadState; 39 class G1CMTask; 40 class ReferenceProcessor; 41 42 class G1ScanClosureBase : public BasicOopIterateClosure { 43 protected: 44 G1CollectedHeap* _g1h; 45 G1ParScanThreadState* _par_scan_state; 46 bool _from_is_young; 47 48 G1ScanClosureBase(G1CollectedHeap* g1h, G1ParScanThreadState* par_scan_state); 49 ~G1ScanClosureBase() { } 50 51 template <class T> 52 inline void prefetch_and_push(T* p, oop const obj); 53 54 template <class T> 55 inline void handle_non_cset_obj_common(InCSetState const state, T* p, oop const obj); 56 public: 57 virtual ReferenceIterationMode reference_iteration_mode() { return DO_FIELDS; } 58 59 void set_from_is_young(bool from_is_young) { _from_is_young = from_is_young; } 60 61 inline void trim_queue_partially(); 62 }; 63 64 // Used during the Update RS phase to refine remaining cards in the DCQ during garbage collection. 65 class G1ScanObjsDuringUpdateRSClosure : public G1ScanClosureBase { 66 public: 67 G1ScanObjsDuringUpdateRSClosure(G1CollectedHeap* g1h, 68 G1ParScanThreadState* pss) : 69 G1ScanClosureBase(g1h, pss) { } 70 71 template <class T> void do_oop_work(T* p); 72 virtual void do_oop(narrowOop* p) { do_oop_work(p); } 73 virtual void do_oop(oop* p) { do_oop_work(p); } 74 }; 75 76 // Used during the Scan RS phase to scan cards from the remembered set during garbage collection. 77 class G1ScanObjsDuringScanRSClosure : public G1ScanClosureBase { 78 public: 79 G1ScanObjsDuringScanRSClosure(G1CollectedHeap* g1h, 80 G1ParScanThreadState* par_scan_state): 81 G1ScanClosureBase(g1h, par_scan_state) { } 82 83 template <class T> void do_oop_work(T* p); 84 virtual void do_oop(oop* p) { do_oop_work(p); } 85 virtual void do_oop(narrowOop* p) { do_oop_work(p); } 86 }; 87 88 // This closure is applied to the fields of the objects that have just been copied during evacuation. 89 class G1ScanEvacuatedObjClosure : public G1ScanClosureBase { 90 public: 91 G1ScanEvacuatedObjClosure(G1CollectedHeap* g1h, G1ParScanThreadState* par_scan_state) : 92 G1ScanClosureBase(g1h, par_scan_state) { } 93 94 template <class T> void do_oop_work(T* p); 95 virtual void do_oop(oop* p) { do_oop_work(p); } 96 virtual void do_oop(narrowOop* p) { do_oop_work(p); } 97 98 // We need to do reference discovery while processing evacuated objects. 99 virtual ReferenceIterationMode reference_iteration_mode() { return DO_DISCOVERED_AND_DISCOVERY; } 100 101 void set_ref_discoverer(ReferenceDiscoverer* rd) { 102 set_ref_discoverer_internal(rd); 103 } 104 }; 105 106 // Add back base class for metadata 107 class G1ParCopyHelper : public OopClosure { 108 protected: 109 G1CollectedHeap* _g1h; 110 G1ParScanThreadState* _par_scan_state; 111 uint _worker_id; // Cache value from par_scan_state. 112 ClassLoaderData* _scanned_cld; | 26 #define SHARE_VM_GC_G1_G1OOPCLOSURES_HPP 27 28 #include "gc/g1/g1InCSetState.hpp" 29 #include "memory/iterator.hpp" 30 #include "oops/markOop.hpp" 31 32 class HeapRegion; 33 class G1CollectedHeap; 34 class G1RemSet; 35 class G1ConcurrentMark; 36 class DirtyCardToOopClosure; 37 class G1CMBitMap; 38 class G1ParScanThreadState; 39 class G1CMTask; 40 class ReferenceProcessor; 41 42 class G1ScanClosureBase : public BasicOopIterateClosure { 43 protected: 44 G1CollectedHeap* _g1h; 45 G1ParScanThreadState* _par_scan_state; 46 47 G1ScanClosureBase(G1CollectedHeap* g1h, G1ParScanThreadState* par_scan_state); 48 ~G1ScanClosureBase() { } 49 50 template <class T> 51 inline void prefetch_and_push(T* p, oop const obj); 52 53 template <class T> 54 inline void handle_non_cset_obj_common(InCSetState const state, T* p, oop const obj); 55 public: 56 virtual ReferenceIterationMode reference_iteration_mode() { return DO_FIELDS; } 57 58 inline void trim_queue_partially(); 59 }; 60 61 // Used during the Update RS phase to refine remaining cards in the DCQ during garbage collection. 62 class G1ScanObjsDuringUpdateRSClosure : public G1ScanClosureBase { 63 public: 64 G1ScanObjsDuringUpdateRSClosure(G1CollectedHeap* g1h, 65 G1ParScanThreadState* pss) : 66 G1ScanClosureBase(g1h, pss) { } 67 68 template <class T> void do_oop_work(T* p); 69 virtual void do_oop(narrowOop* p) { do_oop_work(p); } 70 virtual void do_oop(oop* p) { do_oop_work(p); } 71 }; 72 73 // Used during the Scan RS phase to scan cards from the remembered set during garbage collection. 74 class G1ScanObjsDuringScanRSClosure : public G1ScanClosureBase { 75 public: 76 G1ScanObjsDuringScanRSClosure(G1CollectedHeap* g1h, 77 G1ParScanThreadState* par_scan_state): 78 G1ScanClosureBase(g1h, par_scan_state) { } 79 80 template <class T> void do_oop_work(T* p); 81 virtual void do_oop(oop* p) { do_oop_work(p); } 82 virtual void do_oop(narrowOop* p) { do_oop_work(p); } 83 }; 84 85 // This closure is applied to the fields of the objects that have just been copied during evacuation. 86 class G1ScanEvacuatedObjClosure : public G1ScanClosureBase { 87 bool _scanning_in_young; 88 89 public: 90 G1ScanEvacuatedObjClosure(G1CollectedHeap* g1h, G1ParScanThreadState* par_scan_state) : 91 G1ScanClosureBase(g1h, par_scan_state), _scanning_in_young(false) { } 92 93 void set_scanning_in_young(bool scanning_in_young) { _scanning_in_young = scanning_in_young; } 94 95 template <class T> void do_oop_work(T* p); 96 virtual void do_oop(oop* p) { do_oop_work(p); } 97 virtual void do_oop(narrowOop* p) { do_oop_work(p); } 98 99 // We need to do reference discovery while processing evacuated objects. 100 virtual ReferenceIterationMode reference_iteration_mode() { return DO_DISCOVERED_AND_DISCOVERY; } 101 102 void set_ref_discoverer(ReferenceDiscoverer* rd) { 103 set_ref_discoverer_internal(rd); 104 } 105 }; 106 107 // Add back base class for metadata 108 class G1ParCopyHelper : public OopClosure { 109 protected: 110 G1CollectedHeap* _g1h; 111 G1ParScanThreadState* _par_scan_state; 112 uint _worker_id; // Cache value from par_scan_state. 113 ClassLoaderData* _scanned_cld; |