src/hotspot/share/classfile/systemDictionary.cpp
changeset 52587 6cd56deebb0d
parent 52514 f4e3900c8d08
child 53079 22295070fcd3
child 53225 b11483a74e5d
child 53322 8ba5b3c76857
equal deleted inserted replaced
52586:74109912c738 52587:6cd56deebb0d
  1805 // Assumes classes in the SystemDictionary are only unloaded at a safepoint
  1805 // Assumes classes in the SystemDictionary are only unloaded at a safepoint
  1806 // Note: anonymous classes are not in the SD.
  1806 // Note: anonymous classes are not in the SD.
  1807 bool SystemDictionary::do_unloading(GCTimer* gc_timer) {
  1807 bool SystemDictionary::do_unloading(GCTimer* gc_timer) {
  1808 
  1808 
  1809   bool unloading_occurred;
  1809   bool unloading_occurred;
       
  1810   bool is_concurrent = !SafepointSynchronize::is_at_safepoint();
  1810   {
  1811   {
  1811     GCTraceTime(Debug, gc, phases) t("ClassLoaderData", gc_timer);
  1812     GCTraceTime(Debug, gc, phases) t("ClassLoaderData", gc_timer);
  1812 
  1813     assert_locked_or_safepoint(ClassLoaderDataGraph_lock);  // caller locks.
  1813     // First, mark for unload all ClassLoaderData referencing a dead class loader.
  1814     // First, mark for unload all ClassLoaderData referencing a dead class loader.
  1814     unloading_occurred = ClassLoaderDataGraph::do_unloading();
  1815     unloading_occurred = ClassLoaderDataGraph::do_unloading();
  1815     if (unloading_occurred) {
  1816     if (unloading_occurred) {
       
  1817       MutexLockerEx ml2(is_concurrent ? Module_lock : NULL);
  1816       JFR_ONLY(Jfr::on_unloading_classes();)
  1818       JFR_ONLY(Jfr::on_unloading_classes();)
       
  1819       MutexLockerEx ml1(is_concurrent ? SystemDictionary_lock : NULL);
  1817       ClassLoaderDataGraph::clean_module_and_package_info();
  1820       ClassLoaderDataGraph::clean_module_and_package_info();
  1818     }
  1821     }
  1819   }
  1822   }
  1820 
  1823 
  1821   // TODO: just return if !unloading_occurred.
  1824   // Cleanup ResolvedMethodTable even if no unloading occurred.
       
  1825   {
       
  1826     GCTraceTime(Debug, gc, phases) t("ResolvedMethodTable", gc_timer);
       
  1827     ResolvedMethodTable::trigger_cleanup();
       
  1828   }
       
  1829 
  1822   if (unloading_occurred) {
  1830   if (unloading_occurred) {
  1823     {
  1831     {
  1824       GCTraceTime(Debug, gc, phases) t("SymbolTable", gc_timer);
  1832       GCTraceTime(Debug, gc, phases) t("SymbolTable", gc_timer);
  1825       // Check if there's work to do in the SymbolTable
  1833       // Check if there's work to do in the SymbolTable
  1826       SymbolTable::do_check_concurrent_work();
  1834       SymbolTable::do_check_concurrent_work();
  1827     }
  1835     }
  1828 
  1836 
  1829     {
  1837     {
       
  1838       MutexLockerEx ml(is_concurrent ? SystemDictionary_lock : NULL);
  1830       GCTraceTime(Debug, gc, phases) t("Dictionary", gc_timer);
  1839       GCTraceTime(Debug, gc, phases) t("Dictionary", gc_timer);
  1831       constraints()->purge_loader_constraints();
  1840       constraints()->purge_loader_constraints();
  1832       resolution_errors()->purge_resolution_errors();
  1841       resolution_errors()->purge_resolution_errors();
  1833     }
  1842     }
  1834   }
  1843 
  1835 
  1844     {
  1836   {
  1845       GCTraceTime(Debug, gc, phases) t("ResolvedMethodTable", gc_timer);
  1837     GCTraceTime(Debug, gc, phases) t("ProtectionDomainCacheTable", gc_timer);
  1846       // Oops referenced by the protection domain cache table may get unreachable independently
  1838     // Oops referenced by the protection domain cache table may get unreachable independently
  1847       // of the class loader (eg. cached protection domain oops). So we need to
  1839     // of the class loader (eg. cached protection domain oops). So we need to
  1848       // explicitly unlink them here.
  1840     // explicitly unlink them here.
  1849       // All protection domain oops are linked to the caller class, so if nothing
  1841     _pd_cache_table->trigger_cleanup();
  1850       // unloads, this is not needed.
  1842   }
  1851       _pd_cache_table->trigger_cleanup();
  1843 
  1852     }
  1844   {
       
  1845     GCTraceTime(Debug, gc, phases) t("ResolvedMethodTable", gc_timer);
       
  1846     ResolvedMethodTable::trigger_cleanup();
       
  1847   }
  1853   }
  1848 
  1854 
  1849   return unloading_occurred;
  1855   return unloading_occurred;
  1850 }
  1856 }
  1851 
  1857