178 |
178 |
179 return false; |
179 return false; |
180 } |
180 } |
181 }; |
181 }; |
182 |
182 |
183 class ParClearNextMarkBitmapTask : public AbstractGangTask { |
|
184 ClearBitmapHRClosure* _cl; |
|
185 HeapRegionClaimer _hrclaimer; |
|
186 bool _suspendible; // If the task is suspendible, workers must join the STS. |
|
187 |
|
188 public: |
|
189 ParClearNextMarkBitmapTask(ClearBitmapHRClosure *cl, uint n_workers, bool suspendible) : |
|
190 _cl(cl), _suspendible(suspendible), AbstractGangTask("Parallel Clear Bitmap Task"), _hrclaimer(n_workers) {} |
|
191 |
|
192 void work(uint worker_id) { |
|
193 if (_suspendible) { |
|
194 SuspendibleThreadSet::join(); |
|
195 } |
|
196 G1CollectedHeap::heap()->heap_region_par_iterate(_cl, worker_id, &_hrclaimer); |
|
197 if (_suspendible) { |
|
198 SuspendibleThreadSet::leave(); |
|
199 } |
|
200 } |
|
201 }; |
|
202 |
|
203 void CMBitMap::clearAll() { |
183 void CMBitMap::clearAll() { |
204 G1CollectedHeap* g1h = G1CollectedHeap::heap(); |
|
205 ClearBitmapHRClosure cl(NULL, this, false /* may_yield */); |
184 ClearBitmapHRClosure cl(NULL, this, false /* may_yield */); |
206 uint n_workers = g1h->workers()->active_workers(); |
185 G1CollectedHeap::heap()->heap_region_iterate(&cl); |
207 ParClearNextMarkBitmapTask task(&cl, n_workers, false); |
|
208 g1h->workers()->run_task(&task); |
|
209 guarantee(cl.complete(), "Must have completed iteration."); |
186 guarantee(cl.complete(), "Must have completed iteration."); |
210 return; |
187 return; |
211 } |
188 } |
212 |
189 |
213 void CMBitMap::markRange(MemRegion mr) { |
190 void CMBitMap::markRange(MemRegion mr) { |
882 // this time no other cycle can start. So, let's make sure that this |
859 // this time no other cycle can start. So, let's make sure that this |
883 // is the case. |
860 // is the case. |
884 guarantee(!g1h->mark_in_progress(), "invariant"); |
861 guarantee(!g1h->mark_in_progress(), "invariant"); |
885 |
862 |
886 ClearBitmapHRClosure cl(this, _nextMarkBitMap, true /* may_yield */); |
863 ClearBitmapHRClosure cl(this, _nextMarkBitMap, true /* may_yield */); |
887 ParClearNextMarkBitmapTask task(&cl, parallel_marking_threads(), true); |
864 g1h->heap_region_iterate(&cl); |
888 _parallel_workers->run_task(&task); |
|
889 |
865 |
890 // Clear the liveness counting data. If the marking has been aborted, the abort() |
866 // Clear the liveness counting data. If the marking has been aborted, the abort() |
891 // call already did that. |
867 // call already did that. |
892 if (cl.complete()) { |
868 if (cl.complete()) { |
893 clear_all_count_data(); |
869 clear_all_count_data(); |