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

src/share/vm/memory/universe.cpp

Print this page
rev 7616 : 8067836: The Universe::flush_foo methods belong in CodeCache.
Summary: Move this code to CodeCache.
Reviewed-by: kbarrett, kvn


1057 
1058   // Initialize performance counters for metaspaces
1059   MetaspaceCounters::initialize_performance_counters();
1060   CompressedClassSpaceCounters::initialize_performance_counters();
1061 
1062   MemoryService::add_metaspace_memory_pools();
1063 
1064   MemoryService::set_universe_heap(Universe::_collectedHeap);
1065 #if INCLUDE_CDS
1066   SharedClassUtil::initialize(CHECK_false);
1067 #endif
1068   return true;
1069 }
1070 
1071 
1072 void Universe::compute_base_vtable_size() {
1073   _base_vtable_size = ClassLoader::compute_Object_vtable();
1074 }
1075 
1076 
1077 // %%% The Universe::flush_foo methods belong in CodeCache.
1078 
1079 // Flushes compiled methods dependent on dependee.
1080 void Universe::flush_dependents_on(instanceKlassHandle dependee) {
1081   assert_lock_strong(Compile_lock);
1082 
1083   if (CodeCache::number_of_nmethods_with_dependencies() == 0) return;
1084 
1085   // CodeCache can only be updated by a thread_in_VM and they will all be
1086   // stopped during the safepoint so CodeCache will be safe to update without
1087   // holding the CodeCache_lock.
1088 
1089   KlassDepChange changes(dependee);
1090 
1091   // Compute the dependent nmethods
1092   if (CodeCache::mark_for_deoptimization(changes) > 0) {
1093     // At least one nmethod has been marked for deoptimization
1094     VM_Deoptimize op;
1095     VMThread::execute(&op);
1096   }
1097 }
1098 
1099 // Flushes compiled methods dependent on a particular CallSite
1100 // instance when its target is different than the given MethodHandle.
1101 void Universe::flush_dependents_on(Handle call_site, Handle method_handle) {
1102   assert_lock_strong(Compile_lock);
1103 
1104   if (CodeCache::number_of_nmethods_with_dependencies() == 0) return;
1105 
1106   // CodeCache can only be updated by a thread_in_VM and they will all be
1107   // stopped during the safepoint so CodeCache will be safe to update without
1108   // holding the CodeCache_lock.
1109 
1110   CallSiteDepChange changes(call_site(), method_handle());
1111 
1112   // Compute the dependent nmethods that have a reference to a
1113   // CallSite object.  We use InstanceKlass::mark_dependent_nmethod
1114   // directly instead of CodeCache::mark_for_deoptimization because we
1115   // want dependents on the call site class only not all classes in
1116   // the ContextStream.
1117   int marked = 0;
1118   {
1119     MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
1120     InstanceKlass* call_site_klass = InstanceKlass::cast(call_site->klass());
1121     marked = call_site_klass->mark_dependent_nmethods(changes);
1122   }
1123   if (marked > 0) {
1124     // At least one nmethod has been marked for deoptimization
1125     VM_Deoptimize op;
1126     VMThread::execute(&op);
1127   }
1128 }
1129 
1130 #ifdef HOTSWAP
1131 // Flushes compiled methods dependent on dependee in the evolutionary sense
1132 void Universe::flush_evol_dependents_on(instanceKlassHandle ev_k_h) {
1133   // --- Compile_lock is not held. However we are at a safepoint.
1134   assert_locked_or_safepoint(Compile_lock);
1135   if (CodeCache::number_of_nmethods_with_dependencies() == 0) return;
1136 
1137   // CodeCache can only be updated by a thread_in_VM and they will all be
1138   // stopped during the safepoint so CodeCache will be safe to update without
1139   // holding the CodeCache_lock.
1140 
1141   // Compute the dependent nmethods
1142   if (CodeCache::mark_for_evol_deoptimization(ev_k_h) > 0) {
1143     // At least one nmethod has been marked for deoptimization
1144 
1145     // All this already happens inside a VM_Operation, so we'll do all the work here.
1146     // Stuff copied from VM_Deoptimize and modified slightly.
1147 
1148     // We do not want any GCs to happen while we are in the middle of this VM operation
1149     ResourceMark rm;
1150     DeoptimizationMarker dm;
1151 
1152     // Deoptimize all activations depending on marked nmethods
1153     Deoptimization::deoptimize_dependents();
1154 
1155     // Make the dependent methods not entrant (in VM_Deoptimize they are made zombies)
1156     CodeCache::make_marked_nmethods_not_entrant();
1157   }
1158 }
1159 #endif // HOTSWAP
1160 
1161 
1162 // Flushes compiled methods dependent on dependee
1163 void Universe::flush_dependents_on_method(methodHandle m_h) {
1164   // --- Compile_lock is not held. However we are at a safepoint.
1165   assert_locked_or_safepoint(Compile_lock);
1166 
1167   // CodeCache can only be updated by a thread_in_VM and they will all be
1168   // stopped dring the safepoint so CodeCache will be safe to update without
1169   // holding the CodeCache_lock.
1170 
1171   // Compute the dependent nmethods
1172   if (CodeCache::mark_for_deoptimization(m_h()) > 0) {
1173     // At least one nmethod has been marked for deoptimization
1174 
1175     // All this already happens inside a VM_Operation, so we'll do all the work here.
1176     // Stuff copied from VM_Deoptimize and modified slightly.
1177 
1178     // We do not want any GCs to happen while we are in the middle of this VM operation
1179     ResourceMark rm;
1180     DeoptimizationMarker dm;
1181 
1182     // Deoptimize all activations depending on marked nmethods
1183     Deoptimization::deoptimize_dependents();
1184 
1185     // Make the dependent methods not entrant (in VM_Deoptimize they are made zombies)
1186     CodeCache::make_marked_nmethods_not_entrant();
1187   }
1188 }
1189 
1190 void Universe::print() {
1191   print_on(gclog_or_tty);
1192 }
1193 
1194 void Universe::print_on(outputStream* st, bool extended) {
1195   st->print_cr("Heap");
1196   if (!extended) {
1197     heap()->print_on(st);
1198   } else {
1199     heap()->print_extended_on(st);
1200   }
1201 }
1202 
1203 void Universe::print_heap_at_SIGBREAK() {
1204   if (PrintHeapAtSIGBREAK) {
1205     MutexLocker hl(Heap_lock);
1206     print_on(tty);
1207     tty->cr();
1208     tty->flush();
1209   }




1057 
1058   // Initialize performance counters for metaspaces
1059   MetaspaceCounters::initialize_performance_counters();
1060   CompressedClassSpaceCounters::initialize_performance_counters();
1061 
1062   MemoryService::add_metaspace_memory_pools();
1063 
1064   MemoryService::set_universe_heap(Universe::_collectedHeap);
1065 #if INCLUDE_CDS
1066   SharedClassUtil::initialize(CHECK_false);
1067 #endif
1068   return true;
1069 }
1070 
1071 
1072 void Universe::compute_base_vtable_size() {
1073   _base_vtable_size = ClassLoader::compute_Object_vtable();
1074 }
1075 
1076 

















































































































1077 void Universe::print() {
1078   print_on(gclog_or_tty);
1079 }
1080 
1081 void Universe::print_on(outputStream* st, bool extended) {
1082   st->print_cr("Heap");
1083   if (!extended) {
1084     heap()->print_on(st);
1085   } else {
1086     heap()->print_extended_on(st);
1087   }
1088 }
1089 
1090 void Universe::print_heap_at_SIGBREAK() {
1091   if (PrintHeapAtSIGBREAK) {
1092     MutexLocker hl(Heap_lock);
1093     print_on(tty);
1094     tty->cr();
1095     tty->flush();
1096   }


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