src/hotspot/share/classfile/systemDictionary.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File open Sdiff src/hotspot/share/classfile

src/hotspot/share/classfile/systemDictionary.cpp

Print this page




  87 #if INCLUDE_JVMCI
  88 #include "jvmci/jvmciRuntime.hpp"
  89 #endif
  90 
  91 PlaceholderTable*      SystemDictionary::_placeholders        = NULL;
  92 Dictionary*            SystemDictionary::_shared_dictionary   = NULL;
  93 LoaderConstraintTable* SystemDictionary::_loader_constraints  = NULL;
  94 ResolutionErrorTable*  SystemDictionary::_resolution_errors   = NULL;
  95 SymbolPropertyTable*   SystemDictionary::_invoke_method_table = NULL;
  96 ProtectionDomainCacheTable*   SystemDictionary::_pd_cache_table = NULL;
  97 
  98 int         SystemDictionary::_number_of_modifications = 0;
  99 oop         SystemDictionary::_system_loader_lock_obj     =  NULL;
 100 
 101 InstanceKlass*      SystemDictionary::_well_known_klasses[SystemDictionary::WKID_LIMIT]
 102                                                           =  { NULL /*, NULL...*/ };
 103 
 104 InstanceKlass*      SystemDictionary::_box_klasses[T_VOID+1]      =  { NULL /*, NULL...*/ };
 105 
 106 oop         SystemDictionary::_java_system_loader         =  NULL;

 107 
 108 bool        SystemDictionary::_has_loadClassInternal      =  false;
 109 bool        SystemDictionary::_has_checkPackageAccess     =  false;
 110 
 111 // lazily initialized klass variables
 112 InstanceKlass* volatile SystemDictionary::_abstract_ownable_synchronizer_klass = NULL;
 113 
 114 // Default ProtectionDomainCacheSize value
 115 
 116 const int defaultProtectionDomainCacheSize = 1009;
 117 
 118 
 119 // ----------------------------------------------------------------------------
 120 // Java-level SystemLoader
 121 
 122 oop SystemDictionary::java_system_loader() {
 123   return _java_system_loader;
 124 }
 125 
 126 void SystemDictionary::compute_java_system_loader(TRAPS) {
 127   Klass* system_klass = WK_KLASS(ClassLoader_klass);



 128   JavaValue result(T_OBJECT);

 129   JavaCalls::call_static(&result,
 130                          WK_KLASS(ClassLoader_klass),
 131                          vmSymbols::getSystemClassLoader_name(),
 132                          vmSymbols::void_classloader_signature(),
 133                          CHECK);
 134 
 135   _java_system_loader = (oop)result.get_jobject();
 136 








 137   CDS_ONLY(SystemDictionaryShared::initialize(CHECK);)
 138 }
 139 
 140 
 141 ClassLoaderData* SystemDictionary::register_loader(Handle class_loader, TRAPS) {
 142   if (class_loader() == NULL) return ClassLoaderData::the_null_class_loader_data();
 143   return ClassLoaderDataGraph::find_or_create(class_loader, THREAD);
 144 }
 145 
 146 // ----------------------------------------------------------------------------
 147 // Parallel class loading check
 148 
 149 bool SystemDictionary::is_parallelCapable(Handle class_loader) {
 150   if (UnsyncloadClass || class_loader.is_null()) return true;
 151   if (AlwaysLockClassLoader) return false;
 152   return java_lang_ClassLoader::parallelCapable(class_loader());
 153 }
 154 // ----------------------------------------------------------------------------
 155 // ParallelDefineClass flag does not apply to bootclass loader
 156 bool SystemDictionary::is_parallelDefine(Handle class_loader) {
 157    if (class_loader.is_null()) return false;
 158    if (AllowParallelDefineClass && java_lang_ClassLoader::parallelCapable(class_loader())) {
 159      return true;
 160    }


1923     // of the class loader (eg. cached protection domain oops). So we need to
1924     // explicitly unlink them here.
1925     _pd_cache_table->unlink(is_alive);
1926 
1927 #ifdef ASSERT
1928     VerifySDReachableAndLiveClosure cl(is_alive);
1929     _pd_cache_table->oops_do(&cl);
1930 #endif
1931   }
1932 
1933   if (do_cleaning) {
1934     GCTraceTime(Debug, gc, phases) t("ResolvedMethodTable", gc_timer);
1935     ResolvedMethodTable::unlink(is_alive);
1936   }
1937 
1938   return unloading_occurred;
1939 }
1940 
1941 void SystemDictionary::roots_oops_do(OopClosure* strong, OopClosure* weak) {
1942   strong->do_oop(&_java_system_loader);

1943   strong->do_oop(&_system_loader_lock_obj);
1944   CDS_ONLY(SystemDictionaryShared::roots_oops_do(strong);)
1945 
1946   // Do strong roots marking if the closures are the same.
1947   if (strong == weak || !ClassUnloading) {
1948     // Only the protection domain oops contain references into the heap. Iterate
1949     // over all of them.
1950     _pd_cache_table->oops_do(strong);
1951   } else {
1952    if (weak != NULL) {
1953      _pd_cache_table->oops_do(weak);
1954    }
1955   }
1956 
1957   // Visit extra methods
1958   invoke_method_table()->oops_do(strong);
1959 
1960   if (weak != NULL) {
1961     ResolvedMethodTable::oops_do(weak);
1962   }
1963 }
1964 
1965 void SystemDictionary::oops_do(OopClosure* f) {
1966   f->do_oop(&_java_system_loader);

1967   f->do_oop(&_system_loader_lock_obj);
1968   CDS_ONLY(SystemDictionaryShared::oops_do(f);)
1969 
1970   // Only the protection domain oops contain references into the heap. Iterate
1971   // over all of them.
1972   _pd_cache_table->oops_do(f);
1973 
1974   // Visit extra methods
1975   invoke_method_table()->oops_do(f);
1976 
1977   ResolvedMethodTable::oops_do(f);
1978 }
1979 
1980 // CDS: scan and relocate all classes in the system dictionary.
1981 void SystemDictionary::classes_do(MetaspaceClosure* it) {
1982   ClassLoaderData::the_null_class_loader_data()->dictionary()->classes_do(it);
1983 }
1984 
1985 // CDS: scan and relocate all classes referenced by _well_known_klasses[].
1986 void SystemDictionary::well_known_klasses_do(MetaspaceClosure* it) {




  87 #if INCLUDE_JVMCI
  88 #include "jvmci/jvmciRuntime.hpp"
  89 #endif
  90 
  91 PlaceholderTable*      SystemDictionary::_placeholders        = NULL;
  92 Dictionary*            SystemDictionary::_shared_dictionary   = NULL;
  93 LoaderConstraintTable* SystemDictionary::_loader_constraints  = NULL;
  94 ResolutionErrorTable*  SystemDictionary::_resolution_errors   = NULL;
  95 SymbolPropertyTable*   SystemDictionary::_invoke_method_table = NULL;
  96 ProtectionDomainCacheTable*   SystemDictionary::_pd_cache_table = NULL;
  97 
  98 int         SystemDictionary::_number_of_modifications = 0;
  99 oop         SystemDictionary::_system_loader_lock_obj     =  NULL;
 100 
 101 InstanceKlass*      SystemDictionary::_well_known_klasses[SystemDictionary::WKID_LIMIT]
 102                                                           =  { NULL /*, NULL...*/ };
 103 
 104 InstanceKlass*      SystemDictionary::_box_klasses[T_VOID+1]      =  { NULL /*, NULL...*/ };
 105 
 106 oop         SystemDictionary::_java_system_loader         =  NULL;
 107 oop         SystemDictionary::_java_platform_loader       =  NULL;
 108 
 109 bool        SystemDictionary::_has_loadClassInternal      =  false;
 110 bool        SystemDictionary::_has_checkPackageAccess     =  false;
 111 
 112 // lazily initialized klass variables
 113 InstanceKlass* volatile SystemDictionary::_abstract_ownable_synchronizer_klass = NULL;
 114 
 115 // Default ProtectionDomainCacheSize value
 116 
 117 const int defaultProtectionDomainCacheSize = 1009;
 118 
 119 
 120 // ----------------------------------------------------------------------------
 121 // Java-level SystemLoader and PlatformLoader
 122 
 123 oop SystemDictionary::java_system_loader() {
 124   return _java_system_loader;
 125 }
 126 
 127 oop SystemDictionary::java_platform_loader() {
 128   return _java_platform_loader;
 129 }
 130 
 131 void SystemDictionary::compute_java_loaders(TRAPS) {
 132   JavaValue result(T_OBJECT);
 133   InstanceKlass* class_loader_klass = SystemDictionary::ClassLoader_klass();
 134   JavaCalls::call_static(&result,
 135                          class_loader_klass,
 136                          vmSymbols::getSystemClassLoader_name(),
 137                          vmSymbols::void_classloader_signature(),
 138                          CHECK);
 139 
 140   _java_system_loader = (oop)result.get_jobject();
 141 
 142   JavaCalls::call_static(&result,
 143                          class_loader_klass,
 144                          vmSymbols::getPlatformClassLoader_name(),
 145                          vmSymbols::void_classloader_signature(),
 146                          CHECK);
 147 
 148   _java_platform_loader = (oop)result.get_jobject();
 149 
 150   CDS_ONLY(SystemDictionaryShared::initialize(CHECK);)
 151 }
 152 

 153 ClassLoaderData* SystemDictionary::register_loader(Handle class_loader, TRAPS) {
 154   if (class_loader() == NULL) return ClassLoaderData::the_null_class_loader_data();
 155   return ClassLoaderDataGraph::find_or_create(class_loader, THREAD);
 156 }
 157 
 158 // ----------------------------------------------------------------------------
 159 // Parallel class loading check
 160 
 161 bool SystemDictionary::is_parallelCapable(Handle class_loader) {
 162   if (UnsyncloadClass || class_loader.is_null()) return true;
 163   if (AlwaysLockClassLoader) return false;
 164   return java_lang_ClassLoader::parallelCapable(class_loader());
 165 }
 166 // ----------------------------------------------------------------------------
 167 // ParallelDefineClass flag does not apply to bootclass loader
 168 bool SystemDictionary::is_parallelDefine(Handle class_loader) {
 169    if (class_loader.is_null()) return false;
 170    if (AllowParallelDefineClass && java_lang_ClassLoader::parallelCapable(class_loader())) {
 171      return true;
 172    }


1935     // of the class loader (eg. cached protection domain oops). So we need to
1936     // explicitly unlink them here.
1937     _pd_cache_table->unlink(is_alive);
1938 
1939 #ifdef ASSERT
1940     VerifySDReachableAndLiveClosure cl(is_alive);
1941     _pd_cache_table->oops_do(&cl);
1942 #endif
1943   }
1944 
1945   if (do_cleaning) {
1946     GCTraceTime(Debug, gc, phases) t("ResolvedMethodTable", gc_timer);
1947     ResolvedMethodTable::unlink(is_alive);
1948   }
1949 
1950   return unloading_occurred;
1951 }
1952 
1953 void SystemDictionary::roots_oops_do(OopClosure* strong, OopClosure* weak) {
1954   strong->do_oop(&_java_system_loader);
1955   strong->do_oop(&_java_platform_loader);
1956   strong->do_oop(&_system_loader_lock_obj);
1957   CDS_ONLY(SystemDictionaryShared::roots_oops_do(strong);)
1958 
1959   // Do strong roots marking if the closures are the same.
1960   if (strong == weak || !ClassUnloading) {
1961     // Only the protection domain oops contain references into the heap. Iterate
1962     // over all of them.
1963     _pd_cache_table->oops_do(strong);
1964   } else {
1965    if (weak != NULL) {
1966      _pd_cache_table->oops_do(weak);
1967    }
1968   }
1969 
1970   // Visit extra methods
1971   invoke_method_table()->oops_do(strong);
1972 
1973   if (weak != NULL) {
1974     ResolvedMethodTable::oops_do(weak);
1975   }
1976 }
1977 
1978 void SystemDictionary::oops_do(OopClosure* f) {
1979   f->do_oop(&_java_system_loader);
1980   f->do_oop(&_java_platform_loader);
1981   f->do_oop(&_system_loader_lock_obj);
1982   CDS_ONLY(SystemDictionaryShared::oops_do(f);)
1983 
1984   // Only the protection domain oops contain references into the heap. Iterate
1985   // over all of them.
1986   _pd_cache_table->oops_do(f);
1987 
1988   // Visit extra methods
1989   invoke_method_table()->oops_do(f);
1990 
1991   ResolvedMethodTable::oops_do(f);
1992 }
1993 
1994 // CDS: scan and relocate all classes in the system dictionary.
1995 void SystemDictionary::classes_do(MetaspaceClosure* it) {
1996   ClassLoaderData::the_null_class_loader_data()->dictionary()->classes_do(it);
1997 }
1998 
1999 // CDS: scan and relocate all classes referenced by _well_known_klasses[].
2000 void SystemDictionary::well_known_klasses_do(MetaspaceClosure* it) {


src/hotspot/share/classfile/systemDictionary.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File