comparison src/share/vm/gc_implementation/g1/g1RemSet.hpp @ 845:df6caf649ff7

6700789: G1: Enable use of compressed oops with G1 heaps Summary: Modifications to G1 so as to allow the use of compressed oops. Reviewed-by: apetrusenko, coleenp, jmasa, kvn, never, phh, tonyp
author ysr
date Tue, 14 Jul 2009 15:40:39 -0700
parents 315a5d70b295
children 6cb8e9df7174
comparison
equal deleted inserted replaced
839:bb18957ad21e 845:df6caf649ff7
60 virtual void cleanup_after_oops_into_collection_set_do() = 0; 60 virtual void cleanup_after_oops_into_collection_set_do() = 0;
61 61
62 // If "this" is of the given subtype, return "this", else "NULL". 62 // If "this" is of the given subtype, return "this", else "NULL".
63 virtual HRInto_G1RemSet* as_HRInto_G1RemSet() { return NULL; } 63 virtual HRInto_G1RemSet* as_HRInto_G1RemSet() { return NULL; }
64 64
65 // Record, if necessary, the fact that *p (where "p" is in region "from") 65 // Record, if necessary, the fact that *p (where "p" is in region "from",
66 // has changed to its new value. 66 // and is, a fortiori, required to be non-NULL) has changed to its new value.
67 virtual void write_ref(HeapRegion* from, oop* p) = 0; 67 virtual void write_ref(HeapRegion* from, oop* p) = 0;
68 virtual void write_ref(HeapRegion* from, narrowOop* p) = 0;
68 virtual void par_write_ref(HeapRegion* from, oop* p, int tid) = 0; 69 virtual void par_write_ref(HeapRegion* from, oop* p, int tid) = 0;
70 virtual void par_write_ref(HeapRegion* from, narrowOop* p, int tid) = 0;
69 71
70 // Requires "region_bm" and "card_bm" to be bitmaps with 1 bit per region 72 // Requires "region_bm" and "card_bm" to be bitmaps with 1 bit per region
71 // or card, respectively, such that a region or card with a corresponding 73 // or card, respectively, such that a region or card with a corresponding
72 // 0 bit contains no part of any live object. Eliminates any remembered 74 // 0 bit contains no part of any live object. Eliminates any remembered
73 // set entries that correspond to dead heap ranges. 75 // set entries that correspond to dead heap ranges.
103 void prepare_for_oops_into_collection_set_do() {} 105 void prepare_for_oops_into_collection_set_do() {}
104 void cleanup_after_oops_into_collection_set_do() {} 106 void cleanup_after_oops_into_collection_set_do() {}
105 107
106 // Nothing is necessary in the version below. 108 // Nothing is necessary in the version below.
107 void write_ref(HeapRegion* from, oop* p) {} 109 void write_ref(HeapRegion* from, oop* p) {}
110 void write_ref(HeapRegion* from, narrowOop* p) {}
108 void par_write_ref(HeapRegion* from, oop* p, int tid) {} 111 void par_write_ref(HeapRegion* from, oop* p, int tid) {}
112 void par_write_ref(HeapRegion* from, narrowOop* p, int tid) {}
109 113
110 void scrub(BitMap* region_bm, BitMap* card_bm) {} 114 void scrub(BitMap* region_bm, BitMap* card_bm) {}
111 void scrub_par(BitMap* region_bm, BitMap* card_bm, 115 void scrub_par(BitMap* region_bm, BitMap* card_bm,
112 int worker_num, int claim_val) {} 116 int worker_num, int claim_val) {}
113 117
141 // _par_traversal_in_progress is "true" iff a parallel traversal is in 145 // _par_traversal_in_progress is "true" iff a parallel traversal is in
142 // progress. If so, then cards added to remembered sets should also have 146 // progress. If so, then cards added to remembered sets should also have
143 // their references into the collection summarized in "_new_refs". 147 // their references into the collection summarized in "_new_refs".
144 bool _par_traversal_in_progress; 148 bool _par_traversal_in_progress;
145 void set_par_traversal(bool b) { _par_traversal_in_progress = b; } 149 void set_par_traversal(bool b) { _par_traversal_in_progress = b; }
146 GrowableArray<oop*>** _new_refs; 150 GrowableArray<OopOrNarrowOopStar>** _new_refs;
147 void new_refs_iterate(OopClosure* cl); 151 template <class T> void new_refs_iterate_work(OopClosure* cl);
152 void new_refs_iterate(OopClosure* cl) {
153 if (UseCompressedOops) {
154 new_refs_iterate_work<narrowOop>(cl);
155 } else {
156 new_refs_iterate_work<oop>(cl);
157 }
158 }
159
160 protected:
161 template <class T> void write_ref_nv(HeapRegion* from, T* p);
162 template <class T> void par_write_ref_nv(HeapRegion* from, T* p, int tid);
148 163
149 public: 164 public:
150 // This is called to reset dual hash tables after the gc pause 165 // This is called to reset dual hash tables after the gc pause
151 // is finished and the initial hash table is no longer being 166 // is finished and the initial hash table is no longer being
152 // scanned. 167 // scanned.
159 int worker_i); 174 int worker_i);
160 175
161 void prepare_for_oops_into_collection_set_do(); 176 void prepare_for_oops_into_collection_set_do();
162 void cleanup_after_oops_into_collection_set_do(); 177 void cleanup_after_oops_into_collection_set_do();
163 void scanRS(OopsInHeapRegionClosure* oc, int worker_i); 178 void scanRS(OopsInHeapRegionClosure* oc, int worker_i);
164 void scanNewRefsRS(OopsInHeapRegionClosure* oc, int worker_i); 179 template <class T> void scanNewRefsRS_work(OopsInHeapRegionClosure* oc, int worker_i);
180 void scanNewRefsRS(OopsInHeapRegionClosure* oc, int worker_i) {
181 if (UseCompressedOops) {
182 scanNewRefsRS_work<narrowOop>(oc, worker_i);
183 } else {
184 scanNewRefsRS_work<oop>(oc, worker_i);
185 }
186 }
165 void updateRS(int worker_i); 187 void updateRS(int worker_i);
166 HeapRegion* calculateStartRegion(int i); 188 HeapRegion* calculateStartRegion(int i);
167 189
168 HRInto_G1RemSet* as_HRInto_G1RemSet() { return this; } 190 HRInto_G1RemSet* as_HRInto_G1RemSet() { return this; }
169 191
170 CardTableModRefBS* ct_bs() { return _ct_bs; } 192 CardTableModRefBS* ct_bs() { return _ct_bs; }
171 size_t cardsScanned() { return _total_cards_scanned; } 193 size_t cardsScanned() { return _total_cards_scanned; }
172 194
173 // Record, if necessary, the fact that *p (where "p" is in region "from", 195 // Record, if necessary, the fact that *p (where "p" is in region "from",
174 // which is required to be non-NULL) has changed to a new non-NULL value. 196 // which is required to be non-NULL) has changed to a new non-NULL value.
175 inline void write_ref(HeapRegion* from, oop* p); 197 // [Below the virtual version calls a non-virtual protected
176 // The "_nv" version is the same; it exists just so that it is not virtual. 198 // workhorse that is templatified for narrow vs wide oop.]
177 inline void write_ref_nv(HeapRegion* from, oop* p); 199 inline void write_ref(HeapRegion* from, oop* p) {
178 200 write_ref_nv(from, p);
179 inline bool self_forwarded(oop obj); 201 }
180 inline void par_write_ref(HeapRegion* from, oop* p, int tid); 202 inline void write_ref(HeapRegion* from, narrowOop* p) {
203 write_ref_nv(from, p);
204 }
205 inline void par_write_ref(HeapRegion* from, oop* p, int tid) {
206 par_write_ref_nv(from, p, tid);
207 }
208 inline void par_write_ref(HeapRegion* from, narrowOop* p, int tid) {
209 par_write_ref_nv(from, p, tid);
210 }
211
212 bool self_forwarded(oop obj);
181 213
182 void scrub(BitMap* region_bm, BitMap* card_bm); 214 void scrub(BitMap* region_bm, BitMap* card_bm);
183 void scrub_par(BitMap* region_bm, BitMap* card_bm, 215 void scrub_par(BitMap* region_bm, BitMap* card_bm,
184 int worker_num, int claim_val); 216 int worker_num, int claim_val);
185 217
206 238
207 class UpdateRSOopClosure: public OopClosure { 239 class UpdateRSOopClosure: public OopClosure {
208 HeapRegion* _from; 240 HeapRegion* _from;
209 HRInto_G1RemSet* _rs; 241 HRInto_G1RemSet* _rs;
210 int _worker_i; 242 int _worker_i;
243
244 template <class T> void do_oop_work(T* p);
245
211 public: 246 public:
212 UpdateRSOopClosure(HRInto_G1RemSet* rs, int worker_i = 0) : 247 UpdateRSOopClosure(HRInto_G1RemSet* rs, int worker_i = 0) :
213 _from(NULL), _rs(rs), _worker_i(worker_i) { 248 _from(NULL), _rs(rs), _worker_i(worker_i) {
214 guarantee(_rs != NULL, "Requires an HRIntoG1RemSet"); 249 guarantee(_rs != NULL, "Requires an HRIntoG1RemSet");
215 } 250 }
217 void set_from(HeapRegion* from) { 252 void set_from(HeapRegion* from) {
218 assert(from != NULL, "from region must be non-NULL"); 253 assert(from != NULL, "from region must be non-NULL");
219 _from = from; 254 _from = from;
220 } 255 }
221 256
222 virtual void do_oop(narrowOop* p); 257 virtual void do_oop(narrowOop* p) { do_oop_work(p); }
223 virtual void do_oop(oop* p); 258 virtual void do_oop(oop* p) { do_oop_work(p); }
224 259
225 // Override: this closure is idempotent. 260 // Override: this closure is idempotent.
226 // bool idempotent() { return true; } 261 // bool idempotent() { return true; }
227 bool apply_to_weak_ref_discovered_field() { return true; } 262 bool apply_to_weak_ref_discovered_field() { return true; }
228 }; 263 };
229