24
25 #ifndef SHARE_VM_GC_G1_G1OOPCLOSURES_HPP
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 ExtendedOopClosure {
43 protected:
44 G1CollectedHeap* _g1;
45 G1ParScanThreadState* _par_scan_state;
46 HeapRegion* _from;
47
48 G1ScanClosureBase(G1CollectedHeap* g1, 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 // This closure needs special handling for InstanceRefKlass.
58 virtual ReferenceIterationMode reference_iteration_mode() { return DO_DISCOVERED_AND_DISCOVERY; }
59 void set_region(HeapRegion* from) { _from = from; }
60 };
61
62 // Used during the Update RS phase to refine remaining cards in the DCQ during garbage collection.
63 class G1ScanObjsDuringUpdateRSClosure: public G1ScanClosureBase {
64 uint _worker_i;
65
66 public:
67 G1ScanObjsDuringUpdateRSClosure(G1CollectedHeap* g1h,
68 G1ParScanThreadState* pss,
69 uint worker_i) :
70 G1ScanClosureBase(g1h, pss), _worker_i(worker_i) { }
71
72 template <class T> void do_oop_nv(T* p);
73 virtual void do_oop(narrowOop* p) { do_oop_nv(p); }
74 virtual void do_oop(oop* p) { do_oop_nv(p); }
75 };
76
77 // Used during the Scan RS phase to scan cards from the remembered set during garbage collection.
78 class G1ScanObjsDuringScanRSClosure : public G1ScanClosureBase {
79 public:
80 G1ScanObjsDuringScanRSClosure(G1CollectedHeap* g1,
81 G1ParScanThreadState* par_scan_state):
82 G1ScanClosureBase(g1, par_scan_state) { }
83
84 template <class T> void do_oop_nv(T* p);
85 virtual void do_oop(oop* p) { do_oop_nv(p); }
86 virtual void do_oop(narrowOop* p) { do_oop_nv(p); }
87 };
88
89 // This closure is applied to the fields of the objects that have just been copied during evacuation.
90 class G1ScanEvacuatedObjClosure : public G1ScanClosureBase {
91 public:
92 G1ScanEvacuatedObjClosure(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state) :
93 G1ScanClosureBase(g1, par_scan_state) { }
94
95 template <class T> void do_oop_nv(T* p);
96 virtual void do_oop(oop* p) { do_oop_nv(p); }
97 virtual void do_oop(narrowOop* p) { do_oop_nv(p); }
98
99 void set_ref_processor(ReferenceProcessor* rp) {
100 set_ref_processor_internal(rp);
101 }
102 };
103
104 // Add back base class for metadata
105 class G1ParCopyHelper : public OopClosure {
106 protected:
107 G1CollectedHeap* _g1;
108 G1ParScanThreadState* _par_scan_state;
109 uint _worker_id; // Cache value from par_scan_state.
110 ClassLoaderData* _scanned_cld;
111 G1ConcurrentMark* _cm;
112
113 // Mark the object if it's not already marked. This is used to mark
114 // objects pointed to by roots that are guaranteed not to move
115 // during the GC (i.e., non-CSet objects). It is MT-safe.
116 inline void mark_object(oop obj);
117
118 // Mark the object if it's not already marked. This is used to mark
119 // objects pointed to by roots that have been forwarded during a
120 // GC. It is MT-safe.
121 inline void mark_forwarded_object(oop from_obj, oop to_obj);
122
123 G1ParCopyHelper(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state);
124 ~G1ParCopyHelper() { }
125
126 public:
127 void set_scanned_cld(ClassLoaderData* cld) { _scanned_cld = cld; }
128 inline void do_cld_barrier(oop new_obj);
129 };
130
131 enum G1Barrier {
132 G1BarrierNone,
133 G1BarrierCLD
134 };
135
136 enum G1Mark {
137 G1MarkNone,
138 G1MarkFromRoot,
139 G1MarkPromotedFromRoot
140 };
141
142 template <G1Barrier barrier, G1Mark do_mark_object>
143 class G1ParCopyClosure : public G1ParCopyHelper {
144 public:
145 G1ParCopyClosure(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state) :
146 G1ParCopyHelper(g1, par_scan_state) { }
147
148 template <class T> void do_oop_work(T* p);
149 virtual void do_oop(oop* p) { do_oop_work(p); }
150 virtual void do_oop(narrowOop* p) { do_oop_work(p); }
151 };
152
153 class G1CLDScanClosure : public CLDClosure {
154 G1ParCopyHelper* _closure;
155 bool _process_only_dirty;
156 bool _must_claim;
157 int _count;
158 public:
159 G1CLDScanClosure(G1ParCopyHelper* closure,
160 bool process_only_dirty, bool must_claim)
161 : _process_only_dirty(process_only_dirty), _must_claim(must_claim), _closure(closure), _count(0) {}
162 void do_cld(ClassLoaderData* cld);
163 };
164
165 // Closure for iterating over object fields during concurrent marking
166 class G1CMOopClosure : public MetadataAwareOopClosure {
189
190 class G1ConcurrentRefineOopClosure: public ExtendedOopClosure {
191 G1CollectedHeap* _g1;
192 uint _worker_i;
193
194 public:
195 G1ConcurrentRefineOopClosure(G1CollectedHeap* g1h, uint worker_i) :
196 _g1(g1h),
197 _worker_i(worker_i) {
198 }
199
200 // This closure needs special handling for InstanceRefKlass.
201 virtual ReferenceIterationMode reference_iteration_mode() { return DO_DISCOVERED_AND_DISCOVERY; }
202
203 template <class T> void do_oop_nv(T* p);
204 virtual void do_oop(narrowOop* p) { do_oop_nv(p); }
205 virtual void do_oop(oop* p) { do_oop_nv(p); }
206 };
207
208 class G1RebuildRemSetClosure : public ExtendedOopClosure {
209 G1CollectedHeap* _g1;
210 uint _worker_id;
211 public:
212 G1RebuildRemSetClosure(G1CollectedHeap* g1, uint worker_id) : _g1(g1), _worker_id(worker_id) {
213 }
214
215 template <class T> void do_oop_nv(T* p);
216 virtual void do_oop(oop* p) { do_oop_nv(p); }
217 virtual void do_oop(narrowOop* p) { do_oop_nv(p); }
218 // This closure needs special handling for InstanceRefKlass.
219 virtual ReferenceIterationMode reference_iteration_mode() { return DO_DISCOVERED_AND_DISCOVERY; }
220 };
221
222 #endif // SHARE_VM_GC_G1_G1OOPCLOSURES_HPP
|
24
25 #ifndef SHARE_VM_GC_G1_G1OOPCLOSURES_HPP
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 ExtendedOopClosure {
43 protected:
44 G1CollectedHeap* _g1h;
45 G1ParScanThreadState* _par_scan_state;
46 HeapRegion* _from;
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 // This closure needs special handling for InstanceRefKlass.
58 virtual ReferenceIterationMode reference_iteration_mode() { return DO_DISCOVERED_AND_DISCOVERY; }
59 void set_region(HeapRegion* from) { _from = from; }
60 };
61
62 // Used during the Update RS phase to refine remaining cards in the DCQ during garbage collection.
63 class G1ScanObjsDuringUpdateRSClosure: public G1ScanClosureBase {
64 uint _worker_i;
65
66 public:
67 G1ScanObjsDuringUpdateRSClosure(G1CollectedHeap* g1h,
68 G1ParScanThreadState* pss,
69 uint worker_i) :
70 G1ScanClosureBase(g1h, pss), _worker_i(worker_i) { }
71
72 template <class T> void do_oop_nv(T* p);
73 virtual void do_oop(narrowOop* p) { do_oop_nv(p); }
74 virtual void do_oop(oop* p) { do_oop_nv(p); }
75 };
76
77 // Used during the Scan RS phase to scan cards from the remembered set during garbage collection.
78 class G1ScanObjsDuringScanRSClosure : public G1ScanClosureBase {
79 public:
80 G1ScanObjsDuringScanRSClosure(G1CollectedHeap* g1h,
81 G1ParScanThreadState* par_scan_state):
82 G1ScanClosureBase(g1h, par_scan_state) { }
83
84 template <class T> void do_oop_nv(T* p);
85 virtual void do_oop(oop* p) { do_oop_nv(p); }
86 virtual void do_oop(narrowOop* p) { do_oop_nv(p); }
87 };
88
89 // This closure is applied to the fields of the objects that have just been copied during evacuation.
90 class G1ScanEvacuatedObjClosure : public G1ScanClosureBase {
91 public:
92 G1ScanEvacuatedObjClosure(G1CollectedHeap* g1h, G1ParScanThreadState* par_scan_state) :
93 G1ScanClosureBase(g1h, par_scan_state) { }
94
95 template <class T> void do_oop_nv(T* p);
96 virtual void do_oop(oop* p) { do_oop_nv(p); }
97 virtual void do_oop(narrowOop* p) { do_oop_nv(p); }
98
99 void set_ref_processor(ReferenceProcessor* rp) {
100 set_ref_processor_internal(rp);
101 }
102 };
103
104 // Add back base class for metadata
105 class G1ParCopyHelper : public OopClosure {
106 protected:
107 G1CollectedHeap* _g1h;
108 G1ParScanThreadState* _par_scan_state;
109 uint _worker_id; // Cache value from par_scan_state.
110 ClassLoaderData* _scanned_cld;
111 G1ConcurrentMark* _cm;
112
113 // Mark the object if it's not already marked. This is used to mark
114 // objects pointed to by roots that are guaranteed not to move
115 // during the GC (i.e., non-CSet objects). It is MT-safe.
116 inline void mark_object(oop obj);
117
118 // Mark the object if it's not already marked. This is used to mark
119 // objects pointed to by roots that have been forwarded during a
120 // GC. It is MT-safe.
121 inline void mark_forwarded_object(oop from_obj, oop to_obj);
122
123 G1ParCopyHelper(G1CollectedHeap* g1h, G1ParScanThreadState* par_scan_state);
124 ~G1ParCopyHelper() { }
125
126 public:
127 void set_scanned_cld(ClassLoaderData* cld) { _scanned_cld = cld; }
128 inline void do_cld_barrier(oop new_obj);
129 };
130
131 enum G1Barrier {
132 G1BarrierNone,
133 G1BarrierCLD
134 };
135
136 enum G1Mark {
137 G1MarkNone,
138 G1MarkFromRoot,
139 G1MarkPromotedFromRoot
140 };
141
142 template <G1Barrier barrier, G1Mark do_mark_object>
143 class G1ParCopyClosure : public G1ParCopyHelper {
144 public:
145 G1ParCopyClosure(G1CollectedHeap* g1h, G1ParScanThreadState* par_scan_state) :
146 G1ParCopyHelper(g1h, par_scan_state) { }
147
148 template <class T> void do_oop_work(T* p);
149 virtual void do_oop(oop* p) { do_oop_work(p); }
150 virtual void do_oop(narrowOop* p) { do_oop_work(p); }
151 };
152
153 class G1CLDScanClosure : public CLDClosure {
154 G1ParCopyHelper* _closure;
155 bool _process_only_dirty;
156 bool _must_claim;
157 int _count;
158 public:
159 G1CLDScanClosure(G1ParCopyHelper* closure,
160 bool process_only_dirty, bool must_claim)
161 : _process_only_dirty(process_only_dirty), _must_claim(must_claim), _closure(closure), _count(0) {}
162 void do_cld(ClassLoaderData* cld);
163 };
164
165 // Closure for iterating over object fields during concurrent marking
166 class G1CMOopClosure : public MetadataAwareOopClosure {
189
190 class G1ConcurrentRefineOopClosure: public ExtendedOopClosure {
191 G1CollectedHeap* _g1;
192 uint _worker_i;
193
194 public:
195 G1ConcurrentRefineOopClosure(G1CollectedHeap* g1h, uint worker_i) :
196 _g1(g1h),
197 _worker_i(worker_i) {
198 }
199
200 // This closure needs special handling for InstanceRefKlass.
201 virtual ReferenceIterationMode reference_iteration_mode() { return DO_DISCOVERED_AND_DISCOVERY; }
202
203 template <class T> void do_oop_nv(T* p);
204 virtual void do_oop(narrowOop* p) { do_oop_nv(p); }
205 virtual void do_oop(oop* p) { do_oop_nv(p); }
206 };
207
208 class G1RebuildRemSetClosure : public ExtendedOopClosure {
209 G1CollectedHeap* _g1h;
210 uint _worker_id;
211 public:
212 G1RebuildRemSetClosure(G1CollectedHeap* g1h, uint worker_id) : _g1h(g1h), _worker_id(worker_id) {
213 }
214
215 template <class T> void do_oop_nv(T* p);
216 virtual void do_oop(oop* p) { do_oop_nv(p); }
217 virtual void do_oop(narrowOop* p) { do_oop_nv(p); }
218 // This closure needs special handling for InstanceRefKlass.
219 virtual ReferenceIterationMode reference_iteration_mode() { return DO_DISCOVERED_AND_DISCOVERY; }
220 };
221
222 #endif // SHARE_VM_GC_G1_G1OOPCLOSURES_HPP
|