148 return;
149 }
150
151 size_t gap_size = pointer_delta(end, start);
152 MemRegion mr(start, gap_size);
153 if (gap_size >= CollectedHeap::min_fill_size()) {
154 CollectedHeap::fill_with_objects(start, gap_size);
155
156 HeapWord* end_first_obj = start + ((oop)start)->size();
157 _hr->cross_threshold(start, end_first_obj);
158 // Fill_with_objects() may have created multiple (i.e. two)
159 // objects, as the max_fill_size() is half a region.
160 // After updating the BOT for the first object, also update the
161 // BOT for the second object to make the BOT complete.
162 if (end_first_obj != end) {
163 _hr->cross_threshold(end_first_obj, end);
164 #ifdef ASSERT
165 size_t size_second_obj = ((oop)end_first_obj)->size();
166 HeapWord* end_of_second_obj = end_first_obj + size_second_obj;
167 assert(end == end_of_second_obj,
168 err_msg("More than two objects were used to fill the area from " PTR_FORMAT " to " PTR_FORMAT ", "
169 "second objects size " SIZE_FORMAT " ends at " PTR_FORMAT,
170 p2i(start), p2i(end), size_second_obj, p2i(end_of_second_obj)));
171 #endif
172 }
173 }
174 _cm->clearRangePrevBitmap(mr);
175 }
176
177 void zap_remainder() {
178 zap_dead_objects(_last_forwarded_object_end, _hr->top());
179 }
180 };
181
182 class RemoveSelfForwardPtrHRClosure: public HeapRegionClosure {
183 G1CollectedHeap* _g1h;
184 uint _worker_id;
185 HeapRegionClaimer* _hrclaimer;
186
187 DirtyCardQueue _dcq;
188 UpdateRSetDeferred _update_rset_cl;
189
190 public:
198 }
199
200 size_t remove_self_forward_ptr_by_walking_hr(HeapRegion* hr,
201 bool during_initial_mark) {
202 RemoveSelfForwardPtrObjClosure rspc(hr,
203 &_update_rset_cl,
204 during_initial_mark,
205 _worker_id);
206 _update_rset_cl.set_region(hr);
207 hr->object_iterate(&rspc);
208 // Need to zap the remainder area of the processed region.
209 rspc.zap_remainder();
210
211 return rspc.marked_bytes();
212 }
213
214 bool doHeapRegion(HeapRegion *hr) {
215 bool during_initial_mark = _g1h->collector_state()->during_initial_mark_pause();
216 bool during_conc_mark = _g1h->collector_state()->mark_in_progress();
217
218 assert(!hr->is_pinned(), err_msg("Unexpected pinned region at index %u", hr->hrm_index()));
219 assert(hr->in_collection_set(), "bad CS");
220
221 if (_hrclaimer->claim_region(hr->hrm_index())) {
222 if (hr->evacuation_failed()) {
223 hr->note_self_forwarding_removal_start(during_initial_mark,
224 during_conc_mark);
225 _g1h->check_bitmaps("Self-Forwarding Ptr Removal", hr);
226
227 // In the common case (i.e. when there is no evacuation
228 // failure) we make sure that the following is done when
229 // the region is freed so that it is "ready-to-go" when it's
230 // re-allocated. However, when evacuation failure happens, a
231 // region will remain in the heap and might ultimately be added
232 // to a CSet in the future. So we have to be careful here and
233 // make sure the region's RSet is ready for parallel iteration
234 // whenever this might be required in the future.
235 hr->rem_set()->reset_for_par_iteration();
236 hr->reset_bot();
237
238 size_t live_bytes = remove_self_forward_ptr_by_walking_hr(hr, during_initial_mark);
|
148 return;
149 }
150
151 size_t gap_size = pointer_delta(end, start);
152 MemRegion mr(start, gap_size);
153 if (gap_size >= CollectedHeap::min_fill_size()) {
154 CollectedHeap::fill_with_objects(start, gap_size);
155
156 HeapWord* end_first_obj = start + ((oop)start)->size();
157 _hr->cross_threshold(start, end_first_obj);
158 // Fill_with_objects() may have created multiple (i.e. two)
159 // objects, as the max_fill_size() is half a region.
160 // After updating the BOT for the first object, also update the
161 // BOT for the second object to make the BOT complete.
162 if (end_first_obj != end) {
163 _hr->cross_threshold(end_first_obj, end);
164 #ifdef ASSERT
165 size_t size_second_obj = ((oop)end_first_obj)->size();
166 HeapWord* end_of_second_obj = end_first_obj + size_second_obj;
167 assert(end == end_of_second_obj,
168 "More than two objects were used to fill the area from " PTR_FORMAT " to " PTR_FORMAT ", "
169 "second objects size " SIZE_FORMAT " ends at " PTR_FORMAT,
170 p2i(start), p2i(end), size_second_obj, p2i(end_of_second_obj));
171 #endif
172 }
173 }
174 _cm->clearRangePrevBitmap(mr);
175 }
176
177 void zap_remainder() {
178 zap_dead_objects(_last_forwarded_object_end, _hr->top());
179 }
180 };
181
182 class RemoveSelfForwardPtrHRClosure: public HeapRegionClosure {
183 G1CollectedHeap* _g1h;
184 uint _worker_id;
185 HeapRegionClaimer* _hrclaimer;
186
187 DirtyCardQueue _dcq;
188 UpdateRSetDeferred _update_rset_cl;
189
190 public:
198 }
199
200 size_t remove_self_forward_ptr_by_walking_hr(HeapRegion* hr,
201 bool during_initial_mark) {
202 RemoveSelfForwardPtrObjClosure rspc(hr,
203 &_update_rset_cl,
204 during_initial_mark,
205 _worker_id);
206 _update_rset_cl.set_region(hr);
207 hr->object_iterate(&rspc);
208 // Need to zap the remainder area of the processed region.
209 rspc.zap_remainder();
210
211 return rspc.marked_bytes();
212 }
213
214 bool doHeapRegion(HeapRegion *hr) {
215 bool during_initial_mark = _g1h->collector_state()->during_initial_mark_pause();
216 bool during_conc_mark = _g1h->collector_state()->mark_in_progress();
217
218 assert(!hr->is_pinned(), "Unexpected pinned region at index %u", hr->hrm_index());
219 assert(hr->in_collection_set(), "bad CS");
220
221 if (_hrclaimer->claim_region(hr->hrm_index())) {
222 if (hr->evacuation_failed()) {
223 hr->note_self_forwarding_removal_start(during_initial_mark,
224 during_conc_mark);
225 _g1h->check_bitmaps("Self-Forwarding Ptr Removal", hr);
226
227 // In the common case (i.e. when there is no evacuation
228 // failure) we make sure that the following is done when
229 // the region is freed so that it is "ready-to-go" when it's
230 // re-allocated. However, when evacuation failure happens, a
231 // region will remain in the heap and might ultimately be added
232 // to a CSet in the future. So we have to be careful here and
233 // make sure the region's RSet is ready for parallel iteration
234 // whenever this might be required in the future.
235 hr->rem_set()->reset_for_par_iteration();
236 hr->reset_bot();
237
238 size_t live_bytes = remove_self_forward_ptr_by_walking_hr(hr, during_initial_mark);
|