< prev index next >

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

Print this page




 275 
 276 void ShenandoahConcurrentMark::update_roots(ShenandoahPhaseTimings::Phase root_phase) {
 277   assert(ShenandoahSafepoint::is_at_shenandoah_safepoint(), "Must be at a safepoint");
 278 
 279   bool update_code_cache = true; // initialize to safer value
 280   switch (root_phase) {
 281     case ShenandoahPhaseTimings::update_roots:
 282     case ShenandoahPhaseTimings::final_update_refs_roots:
 283       update_code_cache = false;
 284       break;
 285     case ShenandoahPhaseTimings::full_gc_roots:
 286     case ShenandoahPhaseTimings::degen_gc_update_roots:
 287       update_code_cache = true;
 288       break;
 289     default:
 290       ShouldNotReachHere();
 291   }
 292 
 293   ShenandoahGCPhase phase(root_phase);
 294 
 295 #if COMPILER2_OR_JVMCI
 296   DerivedPointerTable::clear();
 297 #endif
 298 
 299   uint nworkers = _heap->workers()->active_workers();
 300 
 301   ShenandoahRootUpdater root_updater(nworkers, root_phase, update_code_cache);
 302   ShenandoahUpdateRootsTask update_roots(&root_updater);
 303   _heap->workers()->run_task(&update_roots);
 304 
 305 #if COMPILER2_OR_JVMCI
 306   DerivedPointerTable::update_pointers();
 307 #endif
 308 }
 309 
 310 class ShenandoahUpdateThreadRootsTask : public AbstractGangTask {
 311 private:
 312   ShenandoahThreadRoots           _thread_roots;
 313   ShenandoahPhaseTimings::Phase   _phase;
 314 public:
 315   ShenandoahUpdateThreadRootsTask(bool is_par, ShenandoahPhaseTimings::Phase phase) :
 316     AbstractGangTask("Shenandoah Update Thread Roots"),
 317     _thread_roots(is_par),
 318     _phase(phase) {
 319     ShenandoahHeap::heap()->phase_timings()->record_workers_start(_phase);
 320   }
 321 
 322   ~ShenandoahUpdateThreadRootsTask() {
 323     ShenandoahHeap::heap()->phase_timings()->record_workers_end(_phase);
 324   }
 325   void work(uint worker_id) {
 326     ShenandoahUpdateRefsClosure cl;
 327     _thread_roots.oops_do(&cl, NULL, worker_id);
 328   }
 329 };
 330 
 331 void ShenandoahConcurrentMark::update_thread_roots(ShenandoahPhaseTimings::Phase root_phase) {
 332   WorkGang* workers = _heap->workers();
 333   bool is_par = workers->active_workers() > 1;
 334 #if COMPILER2_OR_JVMCI
 335   DerivedPointerTable::clear();
 336 #endif
 337   ShenandoahUpdateThreadRootsTask task(is_par, root_phase);
 338   workers->run_task(&task);
 339 #if COMPILER2_OR_JVMCI
 340   DerivedPointerTable::update_pointers();
 341 #endif
 342 }
 343 
 344 void ShenandoahConcurrentMark::initialize(uint workers) {
 345   _heap = ShenandoahHeap::heap();
 346 
 347   uint num_queues = MAX2(workers, 1U);
 348 
 349   _task_queues = new ShenandoahObjToScanQueueSet((int) num_queues);
 350 
 351   for (uint i = 0; i < num_queues; ++i) {
 352     ShenandoahObjToScanQueue* task_queue = new ShenandoahObjToScanQueue();
 353     task_queue->initialize();
 354     _task_queues->register_queue(i, task_queue);
 355   }
 356 }
 357 
 358 void ShenandoahConcurrentMark::concurrent_scan_code_roots(uint worker_id, ReferenceProcessor* rp) {
 359   if (ShenandoahConcurrentScanCodeRoots && claim_codecache()) {
 360     ShenandoahObjToScanQueue* q = task_queues()->queue(worker_id);
 361     if (!_heap->unload_classes()) {




 275 
 276 void ShenandoahConcurrentMark::update_roots(ShenandoahPhaseTimings::Phase root_phase) {
 277   assert(ShenandoahSafepoint::is_at_shenandoah_safepoint(), "Must be at a safepoint");
 278 
 279   bool update_code_cache = true; // initialize to safer value
 280   switch (root_phase) {
 281     case ShenandoahPhaseTimings::update_roots:
 282     case ShenandoahPhaseTimings::final_update_refs_roots:
 283       update_code_cache = false;
 284       break;
 285     case ShenandoahPhaseTimings::full_gc_roots:
 286     case ShenandoahPhaseTimings::degen_gc_update_roots:
 287       update_code_cache = true;
 288       break;
 289     default:
 290       ShouldNotReachHere();
 291   }
 292 
 293   ShenandoahGCPhase phase(root_phase);
 294 
 295 #if defined(COMPILER2) || INCLUDE_JVMCI
 296   DerivedPointerTable::clear();
 297 #endif
 298 
 299   uint nworkers = _heap->workers()->active_workers();
 300 
 301   ShenandoahRootUpdater root_updater(nworkers, root_phase, update_code_cache);
 302   ShenandoahUpdateRootsTask update_roots(&root_updater);
 303   _heap->workers()->run_task(&update_roots);
 304 
 305 #if defined(COMPILER2) || INCLUDE_JVMCI
 306   DerivedPointerTable::update_pointers();
 307 #endif
 308 }
 309 
 310 class ShenandoahUpdateThreadRootsTask : public AbstractGangTask {
 311 private:
 312   ShenandoahThreadRoots           _thread_roots;
 313   ShenandoahPhaseTimings::Phase   _phase;
 314 public:
 315   ShenandoahUpdateThreadRootsTask(bool is_par, ShenandoahPhaseTimings::Phase phase) :
 316     AbstractGangTask("Shenandoah Update Thread Roots"),
 317     _thread_roots(is_par),
 318     _phase(phase) {
 319     ShenandoahHeap::heap()->phase_timings()->record_workers_start(_phase);
 320   }
 321 
 322   ~ShenandoahUpdateThreadRootsTask() {
 323     ShenandoahHeap::heap()->phase_timings()->record_workers_end(_phase);
 324   }
 325   void work(uint worker_id) {
 326     ShenandoahUpdateRefsClosure cl;
 327     _thread_roots.oops_do(&cl, NULL, worker_id);
 328   }
 329 };
 330 
 331 void ShenandoahConcurrentMark::update_thread_roots(ShenandoahPhaseTimings::Phase root_phase) {
 332   WorkGang* workers = _heap->workers();
 333   bool is_par = workers->active_workers() > 1;



 334   ShenandoahUpdateThreadRootsTask task(is_par, root_phase);
 335   workers->run_task(&task);



 336 }
 337 
 338 void ShenandoahConcurrentMark::initialize(uint workers) {
 339   _heap = ShenandoahHeap::heap();
 340 
 341   uint num_queues = MAX2(workers, 1U);
 342 
 343   _task_queues = new ShenandoahObjToScanQueueSet((int) num_queues);
 344 
 345   for (uint i = 0; i < num_queues; ++i) {
 346     ShenandoahObjToScanQueue* task_queue = new ShenandoahObjToScanQueue();
 347     task_queue->initialize();
 348     _task_queues->register_queue(i, task_queue);
 349   }
 350 }
 351 
 352 void ShenandoahConcurrentMark::concurrent_scan_code_roots(uint worker_id, ReferenceProcessor* rp) {
 353   if (ShenandoahConcurrentScanCodeRoots && claim_codecache()) {
 354     ShenandoahObjToScanQueue* q = task_queues()->queue(worker_id);
 355     if (!_heap->unload_classes()) {


< prev index next >