174 }; |
174 }; |
175 |
175 |
176 class RemoveSelfForwardPtrHRClosure: public HeapRegionClosure { |
176 class RemoveSelfForwardPtrHRClosure: public HeapRegionClosure { |
177 G1CollectedHeap* _g1h; |
177 G1CollectedHeap* _g1h; |
178 ConcurrentMark* _cm; |
178 ConcurrentMark* _cm; |
179 OopsInHeapRegionClosure *_update_rset_cl; |
|
180 uint _worker_id; |
179 uint _worker_id; |
181 |
180 |
|
181 DirtyCardQueue _dcq; |
|
182 UpdateRSetDeferred _update_rset_cl; |
|
183 |
182 public: |
184 public: |
183 RemoveSelfForwardPtrHRClosure(G1CollectedHeap* g1h, |
185 RemoveSelfForwardPtrHRClosure(G1CollectedHeap* g1h, |
184 OopsInHeapRegionClosure* update_rset_cl, |
|
185 uint worker_id) : |
186 uint worker_id) : |
186 _g1h(g1h), _update_rset_cl(update_rset_cl), |
187 _g1h(g1h), _dcq(&g1h->dirty_card_queue_set()), _update_rset_cl(g1h, &_dcq), |
187 _worker_id(worker_id), _cm(_g1h->concurrent_mark()) { } |
188 _worker_id(worker_id), _cm(_g1h->concurrent_mark()) { |
|
189 } |
188 |
190 |
189 bool doHeapRegion(HeapRegion *hr) { |
191 bool doHeapRegion(HeapRegion *hr) { |
190 bool during_initial_mark = _g1h->g1_policy()->during_initial_mark_pause(); |
192 bool during_initial_mark = _g1h->g1_policy()->during_initial_mark_pause(); |
191 bool during_conc_mark = _g1h->mark_in_progress(); |
193 bool during_conc_mark = _g1h->mark_in_progress(); |
192 |
194 |
193 assert(!hr->isHumongous(), "sanity"); |
195 assert(!hr->isHumongous(), "sanity"); |
194 assert(hr->in_collection_set(), "bad CS"); |
196 assert(hr->in_collection_set(), "bad CS"); |
195 |
197 |
196 if (hr->claimHeapRegion(HeapRegion::ParEvacFailureClaimValue)) { |
198 if (hr->claimHeapRegion(HeapRegion::ParEvacFailureClaimValue)) { |
197 if (hr->evacuation_failed()) { |
199 if (hr->evacuation_failed()) { |
198 RemoveSelfForwardPtrObjClosure rspc(_g1h, _cm, hr, _update_rset_cl, |
200 RemoveSelfForwardPtrObjClosure rspc(_g1h, _cm, hr, &_update_rset_cl, |
199 during_initial_mark, |
201 during_initial_mark, |
200 during_conc_mark, |
202 during_conc_mark, |
201 _worker_id); |
203 _worker_id); |
202 |
204 |
203 hr->note_self_forwarding_removal_start(during_initial_mark, |
205 hr->note_self_forwarding_removal_start(during_initial_mark, |
212 // to a CSet in the future. So we have to be careful here and |
214 // to a CSet in the future. So we have to be careful here and |
213 // make sure the region's RSet is ready for parallel iteration |
215 // make sure the region's RSet is ready for parallel iteration |
214 // whenever this might be required in the future. |
216 // whenever this might be required in the future. |
215 hr->rem_set()->reset_for_par_iteration(); |
217 hr->rem_set()->reset_for_par_iteration(); |
216 hr->reset_bot(); |
218 hr->reset_bot(); |
217 _update_rset_cl->set_region(hr); |
219 _update_rset_cl.set_region(hr); |
218 hr->object_iterate(&rspc); |
220 hr->object_iterate(&rspc); |
219 |
221 |
220 hr->rem_set()->clean_strong_code_roots(hr); |
222 hr->rem_set()->clean_strong_code_roots(hr); |
221 |
223 |
222 hr->note_self_forwarding_removal_end(during_initial_mark, |
224 hr->note_self_forwarding_removal_end(during_initial_mark, |
236 G1ParRemoveSelfForwardPtrsTask(G1CollectedHeap* g1h) : |
238 G1ParRemoveSelfForwardPtrsTask(G1CollectedHeap* g1h) : |
237 AbstractGangTask("G1 Remove Self-forwarding Pointers"), |
239 AbstractGangTask("G1 Remove Self-forwarding Pointers"), |
238 _g1h(g1h) { } |
240 _g1h(g1h) { } |
239 |
241 |
240 void work(uint worker_id) { |
242 void work(uint worker_id) { |
241 UpdateRSetImmediate immediate_update(_g1h->g1_rem_set()); |
243 RemoveSelfForwardPtrHRClosure rsfp_cl(_g1h, worker_id); |
242 DirtyCardQueue dcq(&_g1h->dirty_card_queue_set()); |
|
243 UpdateRSetDeferred deferred_update(_g1h, &dcq); |
|
244 |
|
245 OopsInHeapRegionClosure *update_rset_cl = &deferred_update; |
|
246 if (!G1DeferredRSUpdate) { |
|
247 update_rset_cl = &immediate_update; |
|
248 } |
|
249 |
|
250 RemoveSelfForwardPtrHRClosure rsfp_cl(_g1h, update_rset_cl, worker_id); |
|
251 |
244 |
252 HeapRegion* hr = _g1h->start_cset_region_for_worker(worker_id); |
245 HeapRegion* hr = _g1h->start_cset_region_for_worker(worker_id); |
253 _g1h->collection_set_iterate_from(hr, &rsfp_cl); |
246 _g1h->collection_set_iterate_from(hr, &rsfp_cl); |
254 } |
247 } |
255 }; |
248 }; |