1029 // Flushes compiled methods dependent on dependee. 1030 void CodeCache::flush_dependents_on(instanceKlassHandle dependee) { 1031 assert_lock_strong(Compile_lock); 1032 1033 if (number_of_nmethods_with_dependencies() == 0) return; 1034 1035 // CodeCache can only be updated by a thread_in_VM and they will all be 1036 // stopped during the safepoint so CodeCache will be safe to update without 1037 // holding the CodeCache_lock. 1038 1039 KlassDepChange changes(dependee); 1040 1041 // Compute the dependent nmethods 1042 if (mark_for_deoptimization(changes) > 0) { 1043 // At least one nmethod has been marked for deoptimization 1044 VM_Deoptimize op; 1045 VMThread::execute(&op); 1046 } 1047 } 1048 1049 // Flushes compiled methods dependent on a particular CallSite 1050 // instance when its target is different than the given MethodHandle. 1051 void CodeCache::flush_dependents_on(Handle call_site, Handle method_handle) { 1052 assert_lock_strong(Compile_lock); 1053 1054 if (number_of_nmethods_with_dependencies() == 0) return; 1055 1056 // CodeCache can only be updated by a thread_in_VM and they will all be 1057 // stopped during the safepoint so CodeCache will be safe to update without 1058 // holding the CodeCache_lock. 1059 1060 CallSiteDepChange changes(call_site(), method_handle()); 1061 1062 // Compute the dependent nmethods that have a reference to a 1063 // CallSite object. We use InstanceKlass::mark_dependent_nmethod 1064 // directly instead of CodeCache::mark_for_deoptimization because we 1065 // want dependents on the call site class only not all classes in 1066 // the ContextStream. 1067 int marked = 0; 1068 { 1069 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); 1070 InstanceKlass* ctxk = MethodHandles::get_call_site_context(call_site()); 1071 if (ctxk == NULL) { 1072 return; // No dependencies to invalidate yet. 1073 } 1074 marked = ctxk->mark_dependent_nmethods(changes); 1075 } 1076 if (marked > 0) { 1077 // At least one nmethod has been marked for deoptimization 1078 VM_Deoptimize op; 1079 VMThread::execute(&op); 1080 } 1081 } 1082 1083 #ifdef HOTSWAP 1084 // Flushes compiled methods dependent on dependee in the evolutionary sense 1085 void CodeCache::flush_evol_dependents_on(instanceKlassHandle ev_k_h) { 1086 // --- Compile_lock is not held. However we are at a safepoint. 1087 assert_locked_or_safepoint(Compile_lock); 1088 if (number_of_nmethods_with_dependencies() == 0) return; 1089 1090 // CodeCache can only be updated by a thread_in_VM and they will all be 1091 // stopped during the safepoint so CodeCache will be safe to update without 1092 // holding the CodeCache_lock. 1093 1094 // Compute the dependent nmethods 1095 if (mark_for_evol_deoptimization(ev_k_h) > 0) { 1096 // At least one nmethod has been marked for deoptimization 1097 1098 // All this already happens inside a VM_Operation, so we'll do all the work here. 1099 // Stuff copied from VM_Deoptimize and modified slightly. 1100 1101 // We do not want any GCs to happen while we are in the middle of this VM operation 1102 ResourceMark rm; | 1029 // Flushes compiled methods dependent on dependee. 1030 void CodeCache::flush_dependents_on(instanceKlassHandle dependee) { 1031 assert_lock_strong(Compile_lock); 1032 1033 if (number_of_nmethods_with_dependencies() == 0) return; 1034 1035 // CodeCache can only be updated by a thread_in_VM and they will all be 1036 // stopped during the safepoint so CodeCache will be safe to update without 1037 // holding the CodeCache_lock. 1038 1039 KlassDepChange changes(dependee); 1040 1041 // Compute the dependent nmethods 1042 if (mark_for_deoptimization(changes) > 0) { 1043 // At least one nmethod has been marked for deoptimization 1044 VM_Deoptimize op; 1045 VMThread::execute(&op); 1046 } 1047 } 1048 1049 #ifdef HOTSWAP 1050 // Flushes compiled methods dependent on dependee in the evolutionary sense 1051 void CodeCache::flush_evol_dependents_on(instanceKlassHandle ev_k_h) { 1052 // --- Compile_lock is not held. However we are at a safepoint. 1053 assert_locked_or_safepoint(Compile_lock); 1054 if (number_of_nmethods_with_dependencies() == 0) return; 1055 1056 // CodeCache can only be updated by a thread_in_VM and they will all be 1057 // stopped during the safepoint so CodeCache will be safe to update without 1058 // holding the CodeCache_lock. 1059 1060 // Compute the dependent nmethods 1061 if (mark_for_evol_deoptimization(ev_k_h) > 0) { 1062 // At least one nmethod has been marked for deoptimization 1063 1064 // All this already happens inside a VM_Operation, so we'll do all the work here. 1065 // Stuff copied from VM_Deoptimize and modified slightly. 1066 1067 // We do not want any GCs to happen while we are in the middle of this VM operation 1068 ResourceMark rm; |