200 partial_gc->main_loop<false>(worker_id, _terminator);
201
202 }
203 };
204
205 class ShenandoahPartialCollectionCleanupTask : public AbstractGangTask {
206 private:
207 ShenandoahHeap* _heap;
208 public:
209 ShenandoahPartialCollectionCleanupTask() :
210 AbstractGangTask("Shenandoah Partial Collection Cleanup"),
211 _heap(ShenandoahHeap::heap()) {
212 _heap->collection_set()->clear_current_index();
213 }
214
215 void work(uint worker_id) {
216 ShenandoahCollectionSet* cset = _heap->collection_set();
217 ShenandoahHeapRegion* r = cset->claim_next();
218 while (r != NULL) {
219 HeapWord* bottom = r->bottom();
220 HeapWord* top = _heap->complete_top_at_mark_start(r->bottom());
221 if (top > bottom) {
222 _heap->complete_mark_bit_map()->clear_range_large(MemRegion(bottom, top));
223 }
224 r = cset->claim_next();
225 }
226 }
227
228 };
229
230 ShenandoahPartialGC::ShenandoahPartialGC(ShenandoahHeap* heap, size_t num_regions) :
231 _heap(heap),
232 _matrix(heap->connection_matrix()),
233 _root_regions(new ShenandoahHeapRegionSet(num_regions)),
234 _task_queues(new ShenandoahObjToScanQueueSet(heap->max_workers())),
235 _has_work(false) {
236
237 assert(_matrix != NULL, "need matrix");
238
239 uint num_queues = heap->max_workers();
240 for (uint i = 0; i < num_queues; ++i) {
241 ShenandoahObjToScanQueue* task_queue = new ShenandoahObjToScanQueue();
242 task_queue->initialize();
243 _task_queues->register_queue(i, task_queue);
244 }
245
246 from_idxs = NEW_C_HEAP_ARRAY(size_t, ShenandoahPartialInboundThreshold, mtGC);
247 }
248
249 ShenandoahPartialGC::~ShenandoahPartialGC() {
250 FREE_C_HEAP_ARRAY(size_t, from_idxs);
251 }
252
253 bool ShenandoahPartialGC::prepare() {
254 _heap->collection_set()->clear();
255 assert(_heap->collection_set()->count() == 0, "collection set not clear");
256
257 _heap->ensure_parsability(true);
258
259 ShenandoahConnectionMatrix* matrix = _heap->connection_matrix();
260
261 if (UseShenandoahMatrix && PrintShenandoahMatrix) {
262 LogTarget(Info, gc) lt;
263 LogStream ls(lt);
264 _heap->connection_matrix()->print_on(&ls);
265 }
266
267 ShenandoahHeapRegionSet* regions = _heap->regions();
268 ShenandoahCollectionSet* collection_set = _heap->collection_set();
269 size_t num_regions = _heap->num_regions();
270
271 // First pass: reset all roots
272 for (uint to_idx = 0; to_idx < num_regions; to_idx++) {
273 ShenandoahHeapRegion* r = regions->get(to_idx);
274 r->set_root(false);
275 }
276
277 // Second pass: find collection set, and mark root candidates
|
200 partial_gc->main_loop<false>(worker_id, _terminator);
201
202 }
203 };
204
205 class ShenandoahPartialCollectionCleanupTask : public AbstractGangTask {
206 private:
207 ShenandoahHeap* _heap;
208 public:
209 ShenandoahPartialCollectionCleanupTask() :
210 AbstractGangTask("Shenandoah Partial Collection Cleanup"),
211 _heap(ShenandoahHeap::heap()) {
212 _heap->collection_set()->clear_current_index();
213 }
214
215 void work(uint worker_id) {
216 ShenandoahCollectionSet* cset = _heap->collection_set();
217 ShenandoahHeapRegion* r = cset->claim_next();
218 while (r != NULL) {
219 HeapWord* bottom = r->bottom();
220 HeapWord* top = _heap->top_at_mark_start(r->bottom());
221 if (top > bottom) {
222 _heap->mark_bit_map()->clear_range_large(MemRegion(bottom, top));
223 }
224 r = cset->claim_next();
225 }
226 }
227
228 };
229
230 ShenandoahPartialGC::ShenandoahPartialGC(ShenandoahHeap* heap, size_t num_regions) :
231 _heap(heap),
232 _matrix(heap->connection_matrix()),
233 _root_regions(new ShenandoahHeapRegionSet(num_regions)),
234 _task_queues(new ShenandoahObjToScanQueueSet(heap->max_workers())),
235 _has_work(false) {
236
237 assert(_matrix != NULL, "need matrix");
238
239 uint num_queues = heap->max_workers();
240 for (uint i = 0; i < num_queues; ++i) {
241 ShenandoahObjToScanQueue* task_queue = new ShenandoahObjToScanQueue();
242 task_queue->initialize();
243 _task_queues->register_queue(i, task_queue);
244 }
245
246 from_idxs = NEW_C_HEAP_ARRAY(size_t, ShenandoahPartialInboundThreshold, mtGC);
247 }
248
249 ShenandoahPartialGC::~ShenandoahPartialGC() {
250 FREE_C_HEAP_ARRAY(size_t, from_idxs);
251 }
252
253 bool ShenandoahPartialGC::prepare() {
254 _heap->collection_set()->clear();
255 assert(_heap->collection_set()->count() == 0, "collection set not clear");
256
257 _heap->make_tlabs_parsable(true);
258
259 ShenandoahConnectionMatrix* matrix = _heap->connection_matrix();
260
261 if (UseShenandoahMatrix && PrintShenandoahMatrix) {
262 LogTarget(Info, gc) lt;
263 LogStream ls(lt);
264 _heap->connection_matrix()->print_on(&ls);
265 }
266
267 ShenandoahHeapRegionSet* regions = _heap->regions();
268 ShenandoahCollectionSet* collection_set = _heap->collection_set();
269 size_t num_regions = _heap->num_regions();
270
271 // First pass: reset all roots
272 for (uint to_idx = 0; to_idx < num_regions; to_idx++) {
273 ShenandoahHeapRegion* r = regions->get(to_idx);
274 r->set_root(false);
275 }
276
277 // Second pass: find collection set, and mark root candidates
|