< prev index next >

src/hotspot/share/code/codeCache.cpp

Print this page
rev 56251 : imported patch 8226705-v1
rev 56252 : imported patch 8226705-v2


1126     if (!nm->method()->is_method_handle_intrinsic()) {
1127       nm->mark_for_deoptimization();
1128       if (nm->has_evol_metadata()) {
1129         add_to_old_table(nm);
1130       }
1131     }
1132   }
1133 }
1134 
1135 // Flushes compiled methods dependent on redefined classes, that have already been
1136 // marked for deoptimization.
1137 void CodeCache::flush_evol_dependents() {
1138   assert(SafepointSynchronize::is_at_safepoint(), "Can only do this at a safepoint!");
1139 
1140   // CodeCache can only be updated by a thread_in_VM and they will all be
1141   // stopped during the safepoint so CodeCache will be safe to update without
1142   // holding the CodeCache_lock.
1143 
1144   // At least one nmethod has been marked for deoptimization
1145 
1146   // All this already happens inside a VM_Operation, so we'll do all the work here.
1147   // Stuff copied from VM_Deoptimize and modified slightly.
1148 
1149   // We do not want any GCs to happen while we are in the middle of this VM operation
1150   ResourceMark rm;
1151   DeoptimizationMarker dm;
1152 
1153   // Deoptimize all activations depending on marked nmethods
1154   Deoptimization::deoptimize_dependents();
1155 
1156   // Make the dependent methods not entrant
1157   make_marked_nmethods_not_entrant();
1158 }
1159 #endif // INCLUDE_JVMTI
1160 
1161 // Deoptimize all methods
1162 void CodeCache::mark_all_nmethods_for_deoptimization() {
1163   MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
1164   CompiledMethodIterator iter(CompiledMethodIterator::only_alive_and_not_unloading);
1165   while(iter.next()) {
1166     CompiledMethod* nm = iter.method();
1167     if (!nm->method()->is_method_handle_intrinsic()) {
1168       nm->mark_for_deoptimization();
1169     }
1170   }
1171 }
1172 
1173 int CodeCache::mark_for_deoptimization(Method* dependee) {
1174   MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
1175   int number_of_marked_CodeBlobs = 0;
1176 
1177   CompiledMethodIterator iter(CompiledMethodIterator::only_alive_and_not_unloading);
1178   while(iter.next()) {
1179     CompiledMethod* nm = iter.method();
1180     if (nm->is_dependent_on_method(dependee)) {
1181       ResourceMark rm;
1182       nm->mark_for_deoptimization();
1183       number_of_marked_CodeBlobs++;
1184     }
1185   }
1186 
1187   return number_of_marked_CodeBlobs;
1188 }
1189 
1190 void CodeCache::make_marked_nmethods_not_entrant() {
1191   assert_locked_or_safepoint(CodeCache_lock);
1192   CompiledMethodIterator iter(CompiledMethodIterator::only_alive_and_not_unloading);
1193   while(iter.next()) {
1194     CompiledMethod* nm = iter.method();
1195     if (nm->is_marked_for_deoptimization() && !nm->is_not_entrant()) {
1196       nm->make_not_entrant();
1197     }
1198   }
1199 }
1200 
1201 // Flushes compiled methods dependent on dependee.
1202 void CodeCache::flush_dependents_on(InstanceKlass* dependee) {
1203   assert_lock_strong(Compile_lock);
1204 
1205   if (number_of_nmethods_with_dependencies() == 0) return;
1206 
1207   // CodeCache can only be updated by a thread_in_VM and they will all be
1208   // stopped during the safepoint so CodeCache will be safe to update without
1209   // holding the CodeCache_lock.
1210 
1211   KlassDepChange changes(dependee);
1212 
1213   // Compute the dependent nmethods
1214   if (mark_for_deoptimization(changes) > 0) {
1215     // At least one nmethod has been marked for deoptimization
1216     VM_Deoptimize op;
1217     VMThread::execute(&op);
1218   }
1219 }
1220 
1221 // Flushes compiled methods dependent on dependee
1222 void CodeCache::flush_dependents_on_method(const methodHandle& m_h) {
1223   // --- Compile_lock is not held. However we are at a safepoint.
1224   assert_locked_or_safepoint(Compile_lock);
1225 
1226   // CodeCache can only be updated by a thread_in_VM and they will all be
1227   // stopped dring the safepoint so CodeCache will be safe to update without
1228   // holding the CodeCache_lock.
1229 
1230   // Compute the dependent nmethods
1231   if (mark_for_deoptimization(m_h()) > 0) {
1232     // At least one nmethod has been marked for deoptimization
1233 
1234     // All this already happens inside a VM_Operation, so we'll do all the work here.
1235     // Stuff copied from VM_Deoptimize and modified slightly.
1236 
1237     // We do not want any GCs to happen while we are in the middle of this VM operation
1238     ResourceMark rm;
1239     DeoptimizationMarker dm;
1240 
1241     // Deoptimize all activations depending on marked nmethods
1242     Deoptimization::deoptimize_dependents();
1243 
1244     // Make the dependent methods not entrant
1245     make_marked_nmethods_not_entrant();
1246   }
1247 }
1248 
1249 void CodeCache::verify() {
1250   assert_locked_or_safepoint(CodeCache_lock);
1251   FOR_ALL_HEAPS(heap) {
1252     (*heap)->verify();
1253     FOR_ALL_BLOBS(cb, *heap) {
1254       if (cb->is_alive()) {
1255         cb->verify();
1256       }
1257     }
1258   }
1259 }
1260 
1261 // A CodeHeap is full. Print out warning and report event.
1262 PRAGMA_DIAG_PUSH
1263 PRAGMA_FORMAT_NONLITERAL_IGNORED
1264 void CodeCache::report_codemem_full(int code_blob_type, bool print) {
1265   // Get nmethod heap for the given CodeBlobType and build CodeCacheFull event




1126     if (!nm->method()->is_method_handle_intrinsic()) {
1127       nm->mark_for_deoptimization();
1128       if (nm->has_evol_metadata()) {
1129         add_to_old_table(nm);
1130       }
1131     }
1132   }
1133 }
1134 
1135 // Flushes compiled methods dependent on redefined classes, that have already been
1136 // marked for deoptimization.
1137 void CodeCache::flush_evol_dependents() {
1138   assert(SafepointSynchronize::is_at_safepoint(), "Can only do this at a safepoint!");
1139 
1140   // CodeCache can only be updated by a thread_in_VM and they will all be
1141   // stopped during the safepoint so CodeCache will be safe to update without
1142   // holding the CodeCache_lock.
1143 
1144   // At least one nmethod has been marked for deoptimization
1145 
1146   Deoptimization::deoptimize_all_marked();











1147 }
1148 #endif // INCLUDE_JVMTI
1149 
1150 // Mark methods for deopt (if safe or possible).
1151 void CodeCache::mark_all_nmethods_for_deoptimization() {
1152   MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
1153   CompiledMethodIterator iter(CompiledMethodIterator::only_alive_and_not_unloading);
1154   while(iter.next()) {
1155     CompiledMethod* nm = iter.method();
1156     if (!nm->is_native_method()) {
1157       nm->mark_for_deoptimization();
1158     }
1159   }
1160 }
1161 
1162 int CodeCache::mark_for_deoptimization(Method* dependee) {
1163   MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
1164   int number_of_marked_CodeBlobs = 0;
1165 
1166   CompiledMethodIterator iter(CompiledMethodIterator::only_alive_and_not_unloading);
1167   while(iter.next()) {
1168     CompiledMethod* nm = iter.method();
1169     if (nm->is_dependent_on_method(dependee)) {
1170       ResourceMark rm;
1171       nm->mark_for_deoptimization();
1172       number_of_marked_CodeBlobs++;
1173     }
1174   }
1175 
1176   return number_of_marked_CodeBlobs;
1177 }
1178 
1179 void CodeCache::make_marked_nmethods_not_entrant() {
1180   assert_locked_or_safepoint(CodeCache_lock);
1181   CompiledMethodIterator iter(CompiledMethodIterator::only_alive_and_not_unloading);
1182   while(iter.next()) {
1183     CompiledMethod* nm = iter.method();
1184     if (nm->is_marked_for_deoptimization()) {
1185       nm->make_not_entrant();
1186     }
1187   }
1188 }
1189 
1190 // Flushes compiled methods dependent on dependee.
1191 void CodeCache::flush_dependents_on(InstanceKlass* dependee) {
1192   assert_lock_strong(Compile_lock);
1193 
1194   if (number_of_nmethods_with_dependencies() == 0) return;
1195 




1196   KlassDepChange changes(dependee);
1197 
1198   // Compute the dependent nmethods
1199   if (mark_for_deoptimization(changes) > 0) {
1200     // At least one nmethod has been marked for deoptimization
1201     Deoptimization::deoptimize_all_marked();

1202   }
1203 }
1204 
1205 // Flushes compiled methods dependent on dependee
1206 void CodeCache::flush_dependents_on_method(const methodHandle& m_h) {
1207   // --- Compile_lock is not held. However we are at a safepoint.
1208   assert_locked_or_safepoint(Compile_lock);
1209 




1210   // Compute the dependent nmethods
1211   if (mark_for_deoptimization(m_h()) > 0) {
1212     Deoptimization::deoptimize_all_marked();













1213   }
1214 }
1215 
1216 void CodeCache::verify() {
1217   assert_locked_or_safepoint(CodeCache_lock);
1218   FOR_ALL_HEAPS(heap) {
1219     (*heap)->verify();
1220     FOR_ALL_BLOBS(cb, *heap) {
1221       if (cb->is_alive()) {
1222         cb->verify();
1223       }
1224     }
1225   }
1226 }
1227 
1228 // A CodeHeap is full. Print out warning and report event.
1229 PRAGMA_DIAG_PUSH
1230 PRAGMA_FORMAT_NONLITERAL_IGNORED
1231 void CodeCache::report_codemem_full(int code_blob_type, bool print) {
1232   // Get nmethod heap for the given CodeBlobType and build CodeCacheFull event


< prev index next >