hotspot/src/share/vm/memory/universe.cpp
changeset 28374 0558e321c027
parent 28372 ce0aad4b8c44
child 28734 a7ef74a8eca2
equal deleted inserted replaced
28373:26fdc99d32f8 28374:0558e321c027
  1072 void Universe::compute_base_vtable_size() {
  1072 void Universe::compute_base_vtable_size() {
  1073   _base_vtable_size = ClassLoader::compute_Object_vtable();
  1073   _base_vtable_size = ClassLoader::compute_Object_vtable();
  1074 }
  1074 }
  1075 
  1075 
  1076 
  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() {
  1077 void Universe::print() {
  1191   print_on(gclog_or_tty);
  1078   print_on(gclog_or_tty);
  1192 }
  1079 }
  1193 
  1080 
  1194 void Universe::print_on(outputStream* st, bool extended) {
  1081 void Universe::print_on(outputStream* st, bool extended) {