src/share/vm/memory/universe.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot Sdiff src/share/vm/memory

src/share/vm/memory/universe.cpp

Print this page
rev 5732 : [mq]: comments2


1119   Universe::_loader_addClass_cache->init(
1120     SystemDictionary::ClassLoader_klass(), m);
1121 
1122   // Setup method for checking protection domain
1123   InstanceKlass::cast(SystemDictionary::ProtectionDomain_klass())->link_class(CHECK_false);
1124   m = InstanceKlass::cast(SystemDictionary::ProtectionDomain_klass())->
1125             find_method(vmSymbols::impliesCreateAccessControlContext_name(),
1126                         vmSymbols::void_boolean_signature());
1127   // Allow NULL which should only happen with bootstrapping.
1128   if (m != NULL) {
1129     if (m->is_static()) {
1130       // NoSuchMethodException doesn't actually work because it tries to run the
1131       // <init> function before java_lang_Class is linked. Print error and exit.
1132       tty->print_cr("ProtectionDomain.impliesCreateAccessControlContext() has the wrong linkage");
1133       return false; // initialization failed
1134     }
1135     Universe::_pd_implies_cache->init(
1136       SystemDictionary::ProtectionDomain_klass(), m);;
1137   }
1138 
1139   // The folowing is initializing converter functions for serialization in
1140   // JVM.cpp. If we clean up the StrictMath code above we may want to find
1141   // a better solution for this as well.
1142   initialize_converter_functions();
1143 
1144   // This needs to be done before the first scavenge/gc, since
1145   // it's an input to soft ref clearing policy.
1146   {
1147     MutexLocker x(Heap_lock);
1148     Universe::update_heap_info_at_gc();
1149   }
1150 
1151   // ("weak") refs processing infrastructure initialization
1152   Universe::heap()->post_initialize();
1153 
1154   // Initialize performance counters for metaspaces
1155   MetaspaceCounters::initialize_performance_counters();
1156   CompressedClassSpaceCounters::initialize_performance_counters();
1157 
1158   MemoryService::add_metaspace_memory_pools();
1159 


1161 
1162   MemoryService::set_universe_heap(Universe::_collectedHeap);
1163   return true;
1164 }
1165 
1166 
1167 void Universe::compute_base_vtable_size() {
1168   _base_vtable_size = ClassLoader::compute_Object_vtable();
1169 }
1170 
1171 
1172 // %%% The Universe::flush_foo methods belong in CodeCache.
1173 
1174 // Flushes compiled methods dependent on dependee.
1175 void Universe::flush_dependents_on(instanceKlassHandle dependee) {
1176   assert_lock_strong(Compile_lock);
1177 
1178   if (CodeCache::number_of_nmethods_with_dependencies() == 0) return;
1179 
1180   // CodeCache can only be updated by a thread_in_VM and they will all be
1181   // stopped dring the safepoint so CodeCache will be safe to update without
1182   // holding the CodeCache_lock.
1183 
1184   KlassDepChange changes(dependee);
1185 
1186   // Compute the dependent nmethods
1187   if (CodeCache::mark_for_deoptimization(changes) > 0) {
1188     // At least one nmethod has been marked for deoptimization
1189     VM_Deoptimize op;
1190     VMThread::execute(&op);
1191   }
1192 }
1193 
1194 // Flushes compiled methods dependent on a particular CallSite
1195 // instance when its target is different than the given MethodHandle.
1196 void Universe::flush_dependents_on(Handle call_site, Handle method_handle) {
1197   assert_lock_strong(Compile_lock);
1198 
1199   if (CodeCache::number_of_nmethods_with_dependencies() == 0) return;
1200 
1201   // CodeCache can only be updated by a thread_in_VM and they will all be
1202   // stopped dring the safepoint so CodeCache will be safe to update without
1203   // holding the CodeCache_lock.
1204 
1205   CallSiteDepChange changes(call_site(), method_handle());
1206 
1207   // Compute the dependent nmethods that have a reference to a
1208   // CallSite object.  We use InstanceKlass::mark_dependent_nmethod
1209   // directly instead of CodeCache::mark_for_deoptimization because we
1210   // want dependents on the call site class only not all classes in
1211   // the ContextStream.
1212   int marked = 0;
1213   {
1214     MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
1215     InstanceKlass* call_site_klass = InstanceKlass::cast(call_site->klass());
1216     marked = call_site_klass->mark_dependent_nmethods(changes);
1217   }
1218   if (marked > 0) {
1219     // At least one nmethod has been marked for deoptimization
1220     VM_Deoptimize op;
1221     VMThread::execute(&op);
1222   }
1223 }
1224 
1225 #ifdef HOTSWAP
1226 // Flushes compiled methods dependent on dependee in the evolutionary sense
1227 void Universe::flush_evol_dependents_on(instanceKlassHandle ev_k_h) {
1228   // --- Compile_lock is not held. However we are at a safepoint.
1229   assert_locked_or_safepoint(Compile_lock);
1230   if (CodeCache::number_of_nmethods_with_dependencies() == 0) return;
1231 
1232   // CodeCache can only be updated by a thread_in_VM and they will all be
1233   // stopped dring the safepoint so CodeCache will be safe to update without
1234   // holding the CodeCache_lock.
1235 
1236   // Compute the dependent nmethods
1237   if (CodeCache::mark_for_evol_deoptimization(ev_k_h) > 0) {
1238     // At least one nmethod has been marked for deoptimization
1239 
1240     // All this already happens inside a VM_Operation, so we'll do all the work here.
1241     // Stuff copied from VM_Deoptimize and modified slightly.
1242 
1243     // We do not want any GCs to happen while we are in the middle of this VM operation
1244     ResourceMark rm;
1245     DeoptimizationMarker dm;
1246 
1247     // Deoptimize all activations depending on marked nmethods
1248     Deoptimization::deoptimize_dependents();
1249 
1250     // Make the dependent methods not entrant (in VM_Deoptimize they are made zombies)
1251     CodeCache::make_marked_nmethods_not_entrant();
1252   }
1253 }




1119   Universe::_loader_addClass_cache->init(
1120     SystemDictionary::ClassLoader_klass(), m);
1121 
1122   // Setup method for checking protection domain
1123   InstanceKlass::cast(SystemDictionary::ProtectionDomain_klass())->link_class(CHECK_false);
1124   m = InstanceKlass::cast(SystemDictionary::ProtectionDomain_klass())->
1125             find_method(vmSymbols::impliesCreateAccessControlContext_name(),
1126                         vmSymbols::void_boolean_signature());
1127   // Allow NULL which should only happen with bootstrapping.
1128   if (m != NULL) {
1129     if (m->is_static()) {
1130       // NoSuchMethodException doesn't actually work because it tries to run the
1131       // <init> function before java_lang_Class is linked. Print error and exit.
1132       tty->print_cr("ProtectionDomain.impliesCreateAccessControlContext() has the wrong linkage");
1133       return false; // initialization failed
1134     }
1135     Universe::_pd_implies_cache->init(
1136       SystemDictionary::ProtectionDomain_klass(), m);;
1137   }
1138 
1139   // The following is initializing converter functions for serialization in
1140   // JVM.cpp. If we clean up the StrictMath code above we may want to find
1141   // a better solution for this as well.
1142   initialize_converter_functions();
1143 
1144   // This needs to be done before the first scavenge/gc, since
1145   // it's an input to soft ref clearing policy.
1146   {
1147     MutexLocker x(Heap_lock);
1148     Universe::update_heap_info_at_gc();
1149   }
1150 
1151   // ("weak") refs processing infrastructure initialization
1152   Universe::heap()->post_initialize();
1153 
1154   // Initialize performance counters for metaspaces
1155   MetaspaceCounters::initialize_performance_counters();
1156   CompressedClassSpaceCounters::initialize_performance_counters();
1157 
1158   MemoryService::add_metaspace_memory_pools();
1159 


1161 
1162   MemoryService::set_universe_heap(Universe::_collectedHeap);
1163   return true;
1164 }
1165 
1166 
1167 void Universe::compute_base_vtable_size() {
1168   _base_vtable_size = ClassLoader::compute_Object_vtable();
1169 }
1170 
1171 
1172 // %%% The Universe::flush_foo methods belong in CodeCache.
1173 
1174 // Flushes compiled methods dependent on dependee.
1175 void Universe::flush_dependents_on(instanceKlassHandle dependee) {
1176   assert_lock_strong(Compile_lock);
1177 
1178   if (CodeCache::number_of_nmethods_with_dependencies() == 0) return;
1179 
1180   // CodeCache can only be updated by a thread_in_VM and they will all be
1181   // stopped during the safepoint so CodeCache will be safe to update without
1182   // holding the CodeCache_lock.
1183 
1184   KlassDepChange changes(dependee);
1185 
1186   // Compute the dependent nmethods
1187   if (CodeCache::mark_for_deoptimization(changes) > 0) {
1188     // At least one nmethod has been marked for deoptimization
1189     VM_Deoptimize op;
1190     VMThread::execute(&op);
1191   }
1192 }
1193 
1194 // Flushes compiled methods dependent on a particular CallSite
1195 // instance when its target is different than the given MethodHandle.
1196 void Universe::flush_dependents_on(Handle call_site, Handle method_handle) {
1197   assert_lock_strong(Compile_lock);
1198 
1199   if (CodeCache::number_of_nmethods_with_dependencies() == 0) return;
1200 
1201   // CodeCache can only be updated by a thread_in_VM and they will all be
1202   // stopped during the safepoint so CodeCache will be safe to update without
1203   // holding the CodeCache_lock.
1204 
1205   CallSiteDepChange changes(call_site(), method_handle());
1206 
1207   // Compute the dependent nmethods that have a reference to a
1208   // CallSite object.  We use InstanceKlass::mark_dependent_nmethod
1209   // directly instead of CodeCache::mark_for_deoptimization because we
1210   // want dependents on the call site class only not all classes in
1211   // the ContextStream.
1212   int marked = 0;
1213   {
1214     MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
1215     InstanceKlass* call_site_klass = InstanceKlass::cast(call_site->klass());
1216     marked = call_site_klass->mark_dependent_nmethods(changes);
1217   }
1218   if (marked > 0) {
1219     // At least one nmethod has been marked for deoptimization
1220     VM_Deoptimize op;
1221     VMThread::execute(&op);
1222   }
1223 }
1224 
1225 #ifdef HOTSWAP
1226 // Flushes compiled methods dependent on dependee in the evolutionary sense
1227 void Universe::flush_evol_dependents_on(instanceKlassHandle ev_k_h) {
1228   // --- Compile_lock is not held. However we are at a safepoint.
1229   assert_locked_or_safepoint(Compile_lock);
1230   if (CodeCache::number_of_nmethods_with_dependencies() == 0) return;
1231 
1232   // CodeCache can only be updated by a thread_in_VM and they will all be
1233   // stopped during the safepoint so CodeCache will be safe to update without
1234   // holding the CodeCache_lock.
1235 
1236   // Compute the dependent nmethods
1237   if (CodeCache::mark_for_evol_deoptimization(ev_k_h) > 0) {
1238     // At least one nmethod has been marked for deoptimization
1239 
1240     // All this already happens inside a VM_Operation, so we'll do all the work here.
1241     // Stuff copied from VM_Deoptimize and modified slightly.
1242 
1243     // We do not want any GCs to happen while we are in the middle of this VM operation
1244     ResourceMark rm;
1245     DeoptimizationMarker dm;
1246 
1247     // Deoptimize all activations depending on marked nmethods
1248     Deoptimization::deoptimize_dependents();
1249 
1250     // Make the dependent methods not entrant (in VM_Deoptimize they are made zombies)
1251     CodeCache::make_marked_nmethods_not_entrant();
1252   }
1253 }


src/share/vm/memory/universe.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File