< prev index next >

src/hotspot/share/classfile/systemDictionary.cpp

Print this page




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

1852   {
1853     GCTraceTime(Debug, gc, phases) t("ClassLoaderData", gc_timer);
1854 
1855     // First, mark for unload all ClassLoaderData referencing a dead class loader.
1856     unloading_occurred = ClassLoaderDataGraph::do_unloading(do_cleaning);

1857     if (unloading_occurred) {

1858       JFR_ONLY(Jfr::on_unloading_classes();)

1859       ClassLoaderDataGraph::clean_module_and_package_info();
1860     }
1861   }
1862 
1863   // TODO: just return if !unloading_occurred.




1864   if (unloading_occurred) {
1865     {
1866       GCTraceTime(Debug, gc, phases) t("SymbolTable", gc_timer);
1867       // Check if there's work to do in the SymbolTable
1868       SymbolTable::do_check_concurrent_work();
1869     }
1870 
1871     {

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


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




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

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




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 


< prev index next >