< prev index next >

src/hotspot/share/gc/shenandoah/shenandoahConcurrentMark.cpp

Print this page
rev 59439 : 8245825: Shenandoah: Remove diagnostic flag ShenandoahConcurrentScanCodeRoots


 291 
 292   WorkGang* workers = heap->workers();
 293   uint nworkers = workers->active_workers();
 294 
 295   assert(nworkers <= task_queues()->size(), "Just check");
 296 
 297   ShenandoahAllRootScanner root_proc(nworkers, root_phase);
 298   TASKQUEUE_STATS_ONLY(task_queues()->reset_taskqueue_stats());
 299   task_queues()->reserve(nworkers);
 300 
 301   if (heap->has_forwarded_objects()) {
 302     ShenandoahInitMarkRootsTask<RESOLVE> mark_roots(&root_proc);
 303     workers->run_task(&mark_roots);
 304   } else {
 305     // No need to update references, which means the heap is stable.
 306     // Can save time not walking through forwarding pointers.
 307     ShenandoahInitMarkRootsTask<NONE> mark_roots(&root_proc);
 308     workers->run_task(&mark_roots);
 309   }
 310 
 311   if (ShenandoahConcurrentScanCodeRoots) {
 312     clear_claim_codecache();
 313   }
 314 }
 315 
 316 void ShenandoahConcurrentMark::update_roots(ShenandoahPhaseTimings::Phase root_phase) {
 317   assert(ShenandoahSafepoint::is_at_shenandoah_safepoint(), "Must be at a safepoint");
 318   assert(root_phase == ShenandoahPhaseTimings::full_gc_update_roots ||
 319          root_phase == ShenandoahPhaseTimings::degen_gc_update_roots,
 320          "Only for these phases");
 321 
 322   ShenandoahGCPhase phase(root_phase);
 323 
 324   bool check_alive = root_phase == ShenandoahPhaseTimings::degen_gc_update_roots;
 325 
 326 #if COMPILER2_OR_JVMCI
 327   DerivedPointerTable::clear();
 328 #endif
 329 
 330   uint nworkers = _heap->workers()->active_workers();
 331 
 332   ShenandoahRootUpdater root_updater(nworkers, root_phase);
 333   ShenandoahUpdateRootsTask update_roots(&root_updater, check_alive);


 375 #if COMPILER2_OR_JVMCI
 376   DerivedPointerTable::update_pointers();
 377 #endif
 378 }
 379 
 380 void ShenandoahConcurrentMark::initialize(uint workers) {
 381   _heap = ShenandoahHeap::heap();
 382 
 383   uint num_queues = MAX2(workers, 1U);
 384 
 385   _task_queues = new ShenandoahObjToScanQueueSet((int) num_queues);
 386 
 387   for (uint i = 0; i < num_queues; ++i) {
 388     ShenandoahObjToScanQueue* task_queue = new ShenandoahObjToScanQueue();
 389     task_queue->initialize();
 390     _task_queues->register_queue(i, task_queue);
 391   }
 392 }
 393 
 394 void ShenandoahConcurrentMark::concurrent_scan_code_roots(uint worker_id, ReferenceProcessor* rp) {
 395   if (ShenandoahConcurrentScanCodeRoots && claim_codecache()) {
 396     ShenandoahObjToScanQueue* q = task_queues()->queue(worker_id);
 397     if (!_heap->unload_classes()) {
 398       MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
 399       // TODO: We can not honor StringDeduplication here, due to lock ranking
 400       // inversion. So, we may miss some deduplication candidates.
 401       if (_heap->has_forwarded_objects()) {
 402         ShenandoahMarkResolveRefsClosure cl(q, rp);
 403         CodeBlobToOopClosure blobs(&cl, !CodeBlobToOopClosure::FixRelocations);
 404         CodeCache::blobs_do(&blobs);
 405       } else {
 406         ShenandoahMarkRefsClosure cl(q, rp);
 407         CodeBlobToOopClosure blobs(&cl, !CodeBlobToOopClosure::FixRelocations);
 408         CodeCache::blobs_do(&blobs);
 409       }
 410     }
 411   }
 412 }
 413 
 414 void ShenandoahConcurrentMark::mark_from_roots() {
 415   WorkGang* workers = _heap->workers();


 926       if (q->pop(t) ||
 927           queues->steal(worker_id, t)) {
 928         do_task<T>(q, cl, live_data, &t);
 929         work++;
 930       } else {
 931         break;
 932       }
 933     }
 934 
 935     if (work == 0) {
 936       // No work encountered in current stride, try to terminate.
 937       // Need to leave the STS here otherwise it might block safepoints.
 938       ShenandoahSuspendibleThreadSetLeaver stsl(CANCELLABLE && ShenandoahSuspendibleWorkers);
 939       ShenandoahTerminatorTerminator tt(heap);
 940       if (terminator->offer_termination(&tt)) return;
 941     }
 942   }
 943 }
 944 
 945 bool ShenandoahConcurrentMark::claim_codecache() {
 946   assert(ShenandoahConcurrentScanCodeRoots, "must not be called otherwise");
 947   return _claimed_codecache.try_set();
 948 }
 949 
 950 void ShenandoahConcurrentMark::clear_claim_codecache() {
 951   assert(ShenandoahConcurrentScanCodeRoots, "must not be called otherwise");
 952   _claimed_codecache.unset();
 953 }


 291 
 292   WorkGang* workers = heap->workers();
 293   uint nworkers = workers->active_workers();
 294 
 295   assert(nworkers <= task_queues()->size(), "Just check");
 296 
 297   ShenandoahAllRootScanner root_proc(nworkers, root_phase);
 298   TASKQUEUE_STATS_ONLY(task_queues()->reset_taskqueue_stats());
 299   task_queues()->reserve(nworkers);
 300 
 301   if (heap->has_forwarded_objects()) {
 302     ShenandoahInitMarkRootsTask<RESOLVE> mark_roots(&root_proc);
 303     workers->run_task(&mark_roots);
 304   } else {
 305     // No need to update references, which means the heap is stable.
 306     // Can save time not walking through forwarding pointers.
 307     ShenandoahInitMarkRootsTask<NONE> mark_roots(&root_proc);
 308     workers->run_task(&mark_roots);
 309   }
 310 

 311   clear_claim_codecache();

 312 }
 313 
 314 void ShenandoahConcurrentMark::update_roots(ShenandoahPhaseTimings::Phase root_phase) {
 315   assert(ShenandoahSafepoint::is_at_shenandoah_safepoint(), "Must be at a safepoint");
 316   assert(root_phase == ShenandoahPhaseTimings::full_gc_update_roots ||
 317          root_phase == ShenandoahPhaseTimings::degen_gc_update_roots,
 318          "Only for these phases");
 319 
 320   ShenandoahGCPhase phase(root_phase);
 321 
 322   bool check_alive = root_phase == ShenandoahPhaseTimings::degen_gc_update_roots;
 323 
 324 #if COMPILER2_OR_JVMCI
 325   DerivedPointerTable::clear();
 326 #endif
 327 
 328   uint nworkers = _heap->workers()->active_workers();
 329 
 330   ShenandoahRootUpdater root_updater(nworkers, root_phase);
 331   ShenandoahUpdateRootsTask update_roots(&root_updater, check_alive);


 373 #if COMPILER2_OR_JVMCI
 374   DerivedPointerTable::update_pointers();
 375 #endif
 376 }
 377 
 378 void ShenandoahConcurrentMark::initialize(uint workers) {
 379   _heap = ShenandoahHeap::heap();
 380 
 381   uint num_queues = MAX2(workers, 1U);
 382 
 383   _task_queues = new ShenandoahObjToScanQueueSet((int) num_queues);
 384 
 385   for (uint i = 0; i < num_queues; ++i) {
 386     ShenandoahObjToScanQueue* task_queue = new ShenandoahObjToScanQueue();
 387     task_queue->initialize();
 388     _task_queues->register_queue(i, task_queue);
 389   }
 390 }
 391 
 392 void ShenandoahConcurrentMark::concurrent_scan_code_roots(uint worker_id, ReferenceProcessor* rp) {
 393   if (claim_codecache()) {
 394     ShenandoahObjToScanQueue* q = task_queues()->queue(worker_id);
 395     if (!_heap->unload_classes()) {
 396       MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
 397       // TODO: We can not honor StringDeduplication here, due to lock ranking
 398       // inversion. So, we may miss some deduplication candidates.
 399       if (_heap->has_forwarded_objects()) {
 400         ShenandoahMarkResolveRefsClosure cl(q, rp);
 401         CodeBlobToOopClosure blobs(&cl, !CodeBlobToOopClosure::FixRelocations);
 402         CodeCache::blobs_do(&blobs);
 403       } else {
 404         ShenandoahMarkRefsClosure cl(q, rp);
 405         CodeBlobToOopClosure blobs(&cl, !CodeBlobToOopClosure::FixRelocations);
 406         CodeCache::blobs_do(&blobs);
 407       }
 408     }
 409   }
 410 }
 411 
 412 void ShenandoahConcurrentMark::mark_from_roots() {
 413   WorkGang* workers = _heap->workers();


 924       if (q->pop(t) ||
 925           queues->steal(worker_id, t)) {
 926         do_task<T>(q, cl, live_data, &t);
 927         work++;
 928       } else {
 929         break;
 930       }
 931     }
 932 
 933     if (work == 0) {
 934       // No work encountered in current stride, try to terminate.
 935       // Need to leave the STS here otherwise it might block safepoints.
 936       ShenandoahSuspendibleThreadSetLeaver stsl(CANCELLABLE && ShenandoahSuspendibleWorkers);
 937       ShenandoahTerminatorTerminator tt(heap);
 938       if (terminator->offer_termination(&tt)) return;
 939     }
 940   }
 941 }
 942 
 943 bool ShenandoahConcurrentMark::claim_codecache() {

 944   return _claimed_codecache.try_set();
 945 }
 946 
 947 void ShenandoahConcurrentMark::clear_claim_codecache() {

 948   _claimed_codecache.unset();
 949 }
< prev index next >