69 size_t _marked_bytes; |
69 size_t _marked_bytes; |
70 OopsInHeapRegionClosure *_update_rset_cl; |
70 OopsInHeapRegionClosure *_update_rset_cl; |
71 bool _during_initial_mark; |
71 bool _during_initial_mark; |
72 bool _during_conc_mark; |
72 bool _during_conc_mark; |
73 uint _worker_id; |
73 uint _worker_id; |
74 HeapWord* _end_of_last_gap; |
|
75 HeapWord* _last_gap_threshold; |
|
76 HeapWord* _last_obj_threshold; |
|
77 |
74 |
78 public: |
75 public: |
79 RemoveSelfForwardPtrObjClosure(G1CollectedHeap* g1, ConcurrentMark* cm, |
76 RemoveSelfForwardPtrObjClosure(G1CollectedHeap* g1, ConcurrentMark* cm, |
80 HeapRegion* hr, |
77 HeapRegion* hr, |
81 OopsInHeapRegionClosure* update_rset_cl, |
78 OopsInHeapRegionClosure* update_rset_cl, |
84 uint worker_id) : |
81 uint worker_id) : |
85 _g1(g1), _cm(cm), _hr(hr), _marked_bytes(0), |
82 _g1(g1), _cm(cm), _hr(hr), _marked_bytes(0), |
86 _update_rset_cl(update_rset_cl), |
83 _update_rset_cl(update_rset_cl), |
87 _during_initial_mark(during_initial_mark), |
84 _during_initial_mark(during_initial_mark), |
88 _during_conc_mark(during_conc_mark), |
85 _during_conc_mark(during_conc_mark), |
89 _worker_id(worker_id), |
86 _worker_id(worker_id) { } |
90 _end_of_last_gap(hr->bottom()), |
|
91 _last_gap_threshold(hr->bottom()), |
|
92 _last_obj_threshold(hr->bottom()) { } |
|
93 |
87 |
94 size_t marked_bytes() { return _marked_bytes; } |
88 size_t marked_bytes() { return _marked_bytes; } |
95 |
89 |
96 // <original comment> |
90 // <original comment> |
97 // The original idea here was to coalesce evacuated and dead objects. |
91 // The original idea here was to coalesce evacuated and dead objects. |
111 // to coalesce dead objects if we want to. |
105 // to coalesce dead objects if we want to. |
112 void do_object(oop obj) { |
106 void do_object(oop obj) { |
113 HeapWord* obj_addr = (HeapWord*) obj; |
107 HeapWord* obj_addr = (HeapWord*) obj; |
114 assert(_hr->is_in(obj_addr), "sanity"); |
108 assert(_hr->is_in(obj_addr), "sanity"); |
115 size_t obj_size = obj->size(); |
109 size_t obj_size = obj->size(); |
116 HeapWord* obj_end = obj_addr + obj_size; |
110 _hr->update_bot_for_object(obj_addr, obj_size); |
117 |
|
118 if (_end_of_last_gap != obj_addr) { |
|
119 // there was a gap before obj_addr |
|
120 _last_gap_threshold = _hr->cross_threshold(_end_of_last_gap, obj_addr); |
|
121 } |
|
122 |
111 |
123 if (obj->is_forwarded() && obj->forwardee() == obj) { |
112 if (obj->is_forwarded() && obj->forwardee() == obj) { |
124 // The object failed to move. |
113 // The object failed to move. |
125 |
114 |
126 // We consider all objects that we find self-forwarded to be |
115 // We consider all objects that we find self-forwarded to be |
127 // live. What we'll do is that we'll update the prev marking |
116 // live. What we'll do is that we'll update the prev marking |
128 // info so that they are all under PTAMS and explicitly marked. |
117 // info so that they are all under PTAMS and explicitly marked. |
129 if (!_cm->isPrevMarked(obj)) { |
118 _cm->markPrev(obj); |
130 _cm->markPrev(obj); |
|
131 } |
|
132 if (_during_initial_mark) { |
119 if (_during_initial_mark) { |
133 // For the next marking info we'll only mark the |
120 // For the next marking info we'll only mark the |
134 // self-forwarded objects explicitly if we are during |
121 // self-forwarded objects explicitly if we are during |
135 // initial-mark (since, normally, we only mark objects pointed |
122 // initial-mark (since, normally, we only mark objects pointed |
136 // to by roots if we succeed in copying them). By marking all |
123 // to by roots if we succeed in copying them). By marking all |
156 // across an array that was being chunked and looking malformed. |
143 // across an array that was being chunked and looking malformed. |
157 // The problem is that, if evacuation fails, we might have |
144 // The problem is that, if evacuation fails, we might have |
158 // remembered set entries missing given that we skipped cards on |
145 // remembered set entries missing given that we skipped cards on |
159 // the collection set. So, we'll recreate such entries now. |
146 // the collection set. So, we'll recreate such entries now. |
160 obj->oop_iterate(_update_rset_cl); |
147 obj->oop_iterate(_update_rset_cl); |
|
148 assert(_cm->isPrevMarked(obj), "Should be marked!"); |
161 } else { |
149 } else { |
162 |
|
163 // The object has been either evacuated or is dead. Fill it with a |
150 // The object has been either evacuated or is dead. Fill it with a |
164 // dummy object. |
151 // dummy object. |
165 MemRegion mr(obj_addr, obj_size); |
152 MemRegion mr((HeapWord*) obj, obj_size); |
166 CollectedHeap::fill_with_object(mr); |
153 CollectedHeap::fill_with_object(mr); |
167 |
154 } |
168 // must nuke all dead objects which we skipped when iterating over the region |
|
169 _cm->clearRangePrevBitmap(MemRegion(_end_of_last_gap, obj_end)); |
|
170 } |
|
171 _end_of_last_gap = obj_end; |
|
172 _last_obj_threshold = _hr->cross_threshold(obj_addr, obj_end); |
|
173 } |
155 } |
174 }; |
156 }; |
175 |
157 |
176 class RemoveSelfForwardPtrHRClosure: public HeapRegionClosure { |
158 class RemoveSelfForwardPtrHRClosure: public HeapRegionClosure { |
177 G1CollectedHeap* _g1h; |
159 G1CollectedHeap* _g1h; |
197 if (hr->evacuation_failed()) { |
179 if (hr->evacuation_failed()) { |
198 RemoveSelfForwardPtrObjClosure rspc(_g1h, _cm, hr, _update_rset_cl, |
180 RemoveSelfForwardPtrObjClosure rspc(_g1h, _cm, hr, _update_rset_cl, |
199 during_initial_mark, |
181 during_initial_mark, |
200 during_conc_mark, |
182 during_conc_mark, |
201 _worker_id); |
183 _worker_id); |
|
184 |
|
185 MemRegion mr(hr->bottom(), hr->end()); |
|
186 // We'll recreate the prev marking info so we'll first clear |
|
187 // the prev bitmap range for this region. We never mark any |
|
188 // CSet objects explicitly so the next bitmap range should be |
|
189 // cleared anyway. |
|
190 _cm->clearRangePrevBitmap(mr); |
202 |
191 |
203 hr->note_self_forwarding_removal_start(during_initial_mark, |
192 hr->note_self_forwarding_removal_start(during_initial_mark, |
204 during_conc_mark); |
193 during_conc_mark); |
205 _g1h->check_bitmaps("Self-Forwarding Ptr Removal", hr); |
194 _g1h->check_bitmaps("Self-Forwarding Ptr Removal", hr); |
206 |
195 |