< prev index next >

src/hotspot/share/classfile/systemDictionary.cpp

Print this page




1838   // Link into hierachy. Make sure the vtables are initialized before linking into
1839   k->append_to_sibling_list();                    // add to superklass/sibling list
1840   k->process_interfaces(THREAD);                  // handle all "implements" declarations
1841   k->set_init_state(InstanceKlass::loaded);
1842   // Now flush all code that depended on old class hierarchy.
1843   // Note: must be done *after* linking k into the hierarchy (was bug 12/9/97)
1844   // Also, first reinitialize vtable because it may have gotten out of synch
1845   // while the new class wasn't connected to the class hierarchy.
1846   CodeCache::flush_dependents_on(k);
1847 }
1848 
1849 // ----------------------------------------------------------------------------
1850 // GC support
1851 
1852 // Assumes classes in the SystemDictionary are only unloaded at a safepoint
1853 // Note: anonymous classes are not in the SD.
1854 bool SystemDictionary::do_unloading(GCTimer* gc_timer,
1855                                     bool do_cleaning) {
1856 
1857   bool unloading_occurred;

1858   {
1859     GCTraceTime(Debug, gc, phases) t("ClassLoaderData", gc_timer);
1860 
1861     // First, mark for unload all ClassLoaderData referencing a dead class loader.
1862     unloading_occurred = ClassLoaderDataGraph::do_unloading(do_cleaning);

1863     if (unloading_occurred) {

1864       JFR_ONLY(Jfr::on_unloading_classes();)

1865       ClassLoaderDataGraph::clean_module_and_package_info();
1866     }
1867   }
1868 
1869   // TODO: just return if !unloading_occurred.




1870   if (unloading_occurred) {
1871     {
1872       GCTraceTime(Debug, gc, phases) t("SymbolTable", gc_timer);
1873       // Check if there's work to do in the SymbolTable
1874       SymbolTable::do_check_concurrent_work();
1875     }
1876 
1877     {

1878       GCTraceTime(Debug, gc, phases) t("Dictionary", gc_timer);
1879       constraints()->purge_loader_constraints();
1880       resolution_errors()->purge_resolution_errors();
1881     }
1882   }
1883 
1884   {
1885     GCTraceTime(Debug, gc, phases) t("ProtectionDomainCacheTable", gc_timer);
1886     // Oops referenced by the protection domain cache table may get unreachable independently
1887     // of the class loader (eg. cached protection domain oops). So we need to
1888     // explicitly unlink them here.


1889     _pd_cache_table->trigger_cleanup();
1890   }
1891 
1892   if (do_cleaning) {
1893     GCTraceTime(Debug, gc, phases) t("ResolvedMethodTable", gc_timer);
1894     ResolvedMethodTable::trigger_cleanup();
1895   }
1896 
1897   return unloading_occurred;
1898 }
1899 
1900 void SystemDictionary::oops_do(OopClosure* f) {
1901   f->do_oop(&_java_system_loader);
1902   f->do_oop(&_java_platform_loader);
1903   f->do_oop(&_system_loader_lock_obj);
1904   CDS_ONLY(SystemDictionaryShared::oops_do(f);)
1905 
1906   // Visit extra methods
1907   invoke_method_table()->oops_do(f);
1908 }
1909 
1910 // CDS: scan and relocate all classes in the system dictionary.
1911 void SystemDictionary::classes_do(MetaspaceClosure* it) {
1912   ClassLoaderData::the_null_class_loader_data()->dictionary()->classes_do(it);
1913 }
1914 




1838   // Link into hierachy. Make sure the vtables are initialized before linking into
1839   k->append_to_sibling_list();                    // add to superklass/sibling list
1840   k->process_interfaces(THREAD);                  // handle all "implements" declarations
1841   k->set_init_state(InstanceKlass::loaded);
1842   // Now flush all code that depended on old class hierarchy.
1843   // Note: must be done *after* linking k into the hierarchy (was bug 12/9/97)
1844   // Also, first reinitialize vtable because it may have gotten out of synch
1845   // while the new class wasn't connected to the class hierarchy.
1846   CodeCache::flush_dependents_on(k);
1847 }
1848 
1849 // ----------------------------------------------------------------------------
1850 // GC support
1851 
1852 // Assumes classes in the SystemDictionary are only unloaded at a safepoint
1853 // Note: anonymous classes are not in the SD.
1854 bool SystemDictionary::do_unloading(GCTimer* gc_timer,
1855                                     bool do_cleaning) {
1856 
1857   bool unloading_occurred;
1858   bool is_concurrent = SafepointSynchronize::is_at_safepoint();
1859   {
1860     GCTraceTime(Debug, gc, phases) t("ClassLoaderData", gc_timer);
1861     assert_locked_or_safepoint(ClassLoaderDataGraph_lock);  // caller locks.
1862     // First, mark for unload all ClassLoaderData referencing a dead class loader.
1863     unloading_occurred = ClassLoaderDataGraph::do_unloading(do_cleaning);
1864 
1865     if (unloading_occurred) {
1866       MutexLockerEx ml2(is_concurrent ? Module_lock : NULL);
1867       JFR_ONLY(Jfr::on_unloading_classes();)
1868       MutexLockerEx ml1(is_concurrent ? SystemDictionary_lock : NULL);
1869       ClassLoaderDataGraph::clean_module_and_package_info();
1870     }
1871   }
1872 
1873   if (do_cleaning) {
1874     GCTraceTime(Debug, gc, phases) t("ResolvedMethodTable", gc_timer);
1875     ResolvedMethodTable::trigger_cleanup();
1876   }
1877 
1878   if (unloading_occurred) {
1879     {
1880       GCTraceTime(Debug, gc, phases) t("SymbolTable", gc_timer);
1881       // Check if there's work to do in the SymbolTable
1882       SymbolTable::do_check_concurrent_work();
1883     }
1884 
1885     {
1886       MutexLockerEx ml(is_concurrent ? SystemDictionary_lock : NULL);
1887       GCTraceTime(Debug, gc, phases) t("Dictionary", gc_timer);
1888       constraints()->purge_loader_constraints();
1889       resolution_errors()->purge_resolution_errors();
1890     }

1891 
1892     {
1893       GCTraceTime(Debug, gc, phases) t("ProtectionDomainCacheTable", gc_timer);
1894       // Oops referenced by the protection domain cache table may get unreachable independently
1895       // of the class loader (eg. cached protection domain oops). So we need to
1896       // explicitly unlink them here.
1897       // All protection domain oops are linked to the caller class, so if nothing
1898       // unloads, this is not needed.
1899       _pd_cache_table->trigger_cleanup();
1900     }




1901   }
1902 
1903   return unloading_occurred;
1904 }
1905 
1906 void SystemDictionary::oops_do(OopClosure* f) {
1907   f->do_oop(&_java_system_loader);
1908   f->do_oop(&_java_platform_loader);
1909   f->do_oop(&_system_loader_lock_obj);
1910   CDS_ONLY(SystemDictionaryShared::oops_do(f);)
1911 
1912   // Visit extra methods
1913   invoke_method_table()->oops_do(f);
1914 }
1915 
1916 // CDS: scan and relocate all classes in the system dictionary.
1917 void SystemDictionary::classes_do(MetaspaceClosure* it) {
1918   ClassLoaderData::the_null_class_loader_data()->dictionary()->classes_do(it);
1919 }
1920 


< prev index next >