--- a/hotspot/src/share/vm/memory/universe.cpp Thu Aug 11 12:08:11 2011 -0700
+++ b/hotspot/src/share/vm/memory/universe.cpp Tue Aug 16 04:14:05 2011 -0700
@@ -1177,7 +1177,7 @@
// stopped dring the safepoint so CodeCache will be safe to update without
// holding the CodeCache_lock.
- DepChange changes(dependee);
+ KlassDepChange changes(dependee);
// Compute the dependent nmethods
if (CodeCache::mark_for_deoptimization(changes) > 0) {
@@ -1187,6 +1187,37 @@
}
}
+// Flushes compiled methods dependent on a particular CallSite
+// instance when its target is different than the given MethodHandle.
+void Universe::flush_dependents_on(Handle call_site, Handle method_handle) {
+ assert_lock_strong(Compile_lock);
+
+ if (CodeCache::number_of_nmethods_with_dependencies() == 0) return;
+
+ // CodeCache can only be updated by a thread_in_VM and they will all be
+ // stopped dring the safepoint so CodeCache will be safe to update without
+ // holding the CodeCache_lock.
+
+ CallSiteDepChange changes(call_site(), method_handle());
+
+ // Compute the dependent nmethods that have a reference to a
+ // CallSite object. We use instanceKlass::mark_dependent_nmethod
+ // directly instead of CodeCache::mark_for_deoptimization because we
+ // want dependents on the class CallSite only not all classes in the
+ // ContextStream.
+ int marked = 0;
+ {
+ MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
+ instanceKlass* call_site_klass = instanceKlass::cast(SystemDictionary::CallSite_klass());
+ marked = call_site_klass->mark_dependent_nmethods(changes);
+ }
+ if (marked > 0) {
+ // At least one nmethod has been marked for deoptimization
+ VM_Deoptimize op;
+ VMThread::execute(&op);
+ }
+}
+
#ifdef HOTSWAP
// Flushes compiled methods dependent on dependee in the evolutionary sense
void Universe::flush_evol_dependents_on(instanceKlassHandle ev_k_h) {