1674 #ifdef ASSERT
1675 class VerifySDReachableAndLiveClosure : public OopClosure {
1676 private:
1677 BoolObjectClosure* _is_alive;
1678
1679 template <class T> void do_oop_work(T* p) {
1680 oop obj = oopDesc::load_decode_heap_oop(p);
1681 guarantee(_is_alive->do_object_b(obj), "Oop in system dictionary must be live");
1682 }
1683
1684 public:
1685 VerifySDReachableAndLiveClosure(BoolObjectClosure* is_alive) : OopClosure(), _is_alive(is_alive) { }
1686
1687 virtual void do_oop(oop* p) { do_oop_work(p); }
1688 virtual void do_oop(narrowOop* p) { do_oop_work(p); }
1689 };
1690 #endif
1691
1692 // Assumes classes in the SystemDictionary are only unloaded at a safepoint
1693 // Note: anonymous classes are not in the SD.
1694 bool SystemDictionary::do_unloading(BoolObjectClosure* is_alive) {
1695 // First, mark for unload all ClassLoaderData referencing a dead class loader.
1696 bool unloading_occurred = ClassLoaderDataGraph::do_unloading(is_alive);
1697 if (unloading_occurred) {
1698 dictionary()->do_unloading();
1699 constraints()->purge_loader_constraints();
1700 resolution_errors()->purge_resolution_errors();
1701 }
1702 // Oops referenced by the system dictionary may get unreachable independently
1703 // of the class loader (eg. cached protection domain oops). So we need to
1704 // explicitly unlink them here instead of in Dictionary::do_unloading.
1705 dictionary()->unlink(is_alive);
1706 #ifdef ASSERT
1707 VerifySDReachableAndLiveClosure cl(is_alive);
1708 dictionary()->oops_do(&cl);
1709 #endif
1710 return unloading_occurred;
1711 }
1712
1713 void SystemDictionary::roots_oops_do(OopClosure* strong, OopClosure* weak) {
1714 strong->do_oop(&_java_system_loader);
1715 strong->do_oop(&_system_loader_lock_obj);
1716 CDS_ONLY(SystemDictionaryShared::roots_oops_do(strong);)
|
1674 #ifdef ASSERT
1675 class VerifySDReachableAndLiveClosure : public OopClosure {
1676 private:
1677 BoolObjectClosure* _is_alive;
1678
1679 template <class T> void do_oop_work(T* p) {
1680 oop obj = oopDesc::load_decode_heap_oop(p);
1681 guarantee(_is_alive->do_object_b(obj), "Oop in system dictionary must be live");
1682 }
1683
1684 public:
1685 VerifySDReachableAndLiveClosure(BoolObjectClosure* is_alive) : OopClosure(), _is_alive(is_alive) { }
1686
1687 virtual void do_oop(oop* p) { do_oop_work(p); }
1688 virtual void do_oop(narrowOop* p) { do_oop_work(p); }
1689 };
1690 #endif
1691
1692 // Assumes classes in the SystemDictionary are only unloaded at a safepoint
1693 // Note: anonymous classes are not in the SD.
1694 bool SystemDictionary::do_unloading(BoolObjectClosure* is_alive, bool clean_alive) {
1695 // First, mark for unload all ClassLoaderData referencing a dead class loader.
1696 bool unloading_occurred = ClassLoaderDataGraph::do_unloading(is_alive, clean_alive);
1697 if (unloading_occurred) {
1698 dictionary()->do_unloading();
1699 constraints()->purge_loader_constraints();
1700 resolution_errors()->purge_resolution_errors();
1701 }
1702 // Oops referenced by the system dictionary may get unreachable independently
1703 // of the class loader (eg. cached protection domain oops). So we need to
1704 // explicitly unlink them here instead of in Dictionary::do_unloading.
1705 dictionary()->unlink(is_alive);
1706 #ifdef ASSERT
1707 VerifySDReachableAndLiveClosure cl(is_alive);
1708 dictionary()->oops_do(&cl);
1709 #endif
1710 return unloading_occurred;
1711 }
1712
1713 void SystemDictionary::roots_oops_do(OopClosure* strong, OopClosure* weak) {
1714 strong->do_oop(&_java_system_loader);
1715 strong->do_oop(&_system_loader_lock_obj);
1716 CDS_ONLY(SystemDictionaryShared::roots_oops_do(strong);)
|