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