src/hotspot/share/gc/shenandoah/shenandoahConcurrentMark.cpp
changeset 55760 bf8128faace1
parent 55476 aee0d296c0ef
child 57732 23e13076e102
equal deleted inserted replaced
55759:bf9fa29bb3dc 55760:bf8128faace1
   444   // When we're done marking everything, we process weak references.
   444   // When we're done marking everything, we process weak references.
   445   if (_heap->process_references()) {
   445   if (_heap->process_references()) {
   446     weak_refs_work(full_gc);
   446     weak_refs_work(full_gc);
   447   }
   447   }
   448 
   448 
   449   weak_roots_work();
   449   _heap->parallel_cleaning(full_gc);
   450 
   450 
   451   // And finally finish class unloading
       
   452   if (_heap->unload_classes()) {
       
   453     _heap->unload_classes_and_cleanup_tables(full_gc);
       
   454   } else if (ShenandoahStringDedup::is_enabled()) {
       
   455     ShenandoahIsAliveSelector alive;
       
   456     BoolObjectClosure* is_alive = alive.is_alive_closure();
       
   457     ShenandoahStringDedup::unlink_or_oops_do(is_alive, NULL, false);
       
   458   }
       
   459   assert(task_queues()->is_empty(), "Should be empty");
   451   assert(task_queues()->is_empty(), "Should be empty");
   460   TASKQUEUE_STATS_ONLY(task_queues()->print_taskqueue_stats());
   452   TASKQUEUE_STATS_ONLY(task_queues()->print_taskqueue_stats());
   461   TASKQUEUE_STATS_ONLY(task_queues()->reset_taskqueue_stats());
   453   TASKQUEUE_STATS_ONLY(task_queues()->reset_taskqueue_stats());
   462 
       
   463   // Resize Metaspace
       
   464   MetaspaceGC::compute_new_size();
       
   465 }
   454 }
   466 
   455 
   467 // Weak Reference Closures
   456 // Weak Reference Closures
   468 class ShenandoahCMDrainMarkingStackClosure: public VoidClosure {
   457 class ShenandoahCMDrainMarkingStackClosure: public VoidClosure {
   469   uint _worker_id;
   458   uint _worker_id;
   549     shenandoah_assert_marked_except(p, o, o == NULL);
   538     shenandoah_assert_marked_except(p, o, o == NULL);
   550   }
   539   }
   551 
   540 
   552 public:
   541 public:
   553   ShenandoahWeakUpdateClosure() : _heap(ShenandoahHeap::heap()) {}
   542   ShenandoahWeakUpdateClosure() : _heap(ShenandoahHeap::heap()) {}
   554 
       
   555   void do_oop(narrowOop* p) { do_oop_work(p); }
       
   556   void do_oop(oop* p)       { do_oop_work(p); }
       
   557 };
       
   558 
       
   559 class ShenandoahWeakAssertNotForwardedClosure : public OopClosure {
       
   560 private:
       
   561   template <class T>
       
   562   inline void do_oop_work(T* p) {
       
   563 #ifdef ASSERT
       
   564     T o = RawAccess<>::oop_load(p);
       
   565     if (!CompressedOops::is_null(o)) {
       
   566       oop obj = CompressedOops::decode_not_null(o);
       
   567       shenandoah_assert_not_forwarded(p, obj);
       
   568     }
       
   569 #endif
       
   570   }
       
   571 
       
   572 public:
       
   573   ShenandoahWeakAssertNotForwardedClosure() {}
       
   574 
   543 
   575   void do_oop(narrowOop* p) { do_oop_work(p); }
   544   void do_oop(narrowOop* p) { do_oop_work(p); }
   576   void do_oop(oop* p)       { do_oop_work(p); }
   545   void do_oop(oop* p)       { do_oop_work(p); }
   577 };
   546 };
   578 
   547 
   651   weak_refs_work_doit(full_gc);
   620   weak_refs_work_doit(full_gc);
   652 
   621 
   653   rp->verify_no_references_recorded();
   622   rp->verify_no_references_recorded();
   654   assert(!rp->discovery_enabled(), "Post condition");
   623   assert(!rp->discovery_enabled(), "Post condition");
   655 
   624 
   656 }
       
   657 
       
   658 // Process leftover weak oops: update them, if needed or assert they do not
       
   659 // need updating otherwise.
       
   660 // Weak processor API requires us to visit the oops, even if we are not doing
       
   661 // anything to them.
       
   662 void ShenandoahConcurrentMark::weak_roots_work() {
       
   663   WorkGang* workers = _heap->workers();
       
   664   OopClosure* keep_alive = &do_nothing_cl;
       
   665 #ifdef ASSERT
       
   666   ShenandoahWeakAssertNotForwardedClosure verify_cl;
       
   667   keep_alive = &verify_cl;
       
   668 #endif
       
   669   ShenandoahIsAliveClosure is_alive;
       
   670   WeakProcessor::weak_oops_do(workers, &is_alive, keep_alive, 1);
       
   671 }
   625 }
   672 
   626 
   673 void ShenandoahConcurrentMark::weak_refs_work_doit(bool full_gc) {
   627 void ShenandoahConcurrentMark::weak_refs_work_doit(bool full_gc) {
   674   ReferenceProcessor* rp = _heap->ref_processor();
   628   ReferenceProcessor* rp = _heap->ref_processor();
   675 
   629