hotspot/src/share/vm/code/nmethod.cpp
changeset 31037 01a5c5fa5681
parent 30628 3c15b4a3bf4d
child 31348 c28f02c7abb5
--- a/hotspot/src/share/vm/code/nmethod.cpp	Fri May 15 19:21:46 2015 +0300
+++ b/hotspot/src/share/vm/code/nmethod.cpp	Fri May 15 19:23:11 2015 +0300
@@ -565,13 +565,18 @@
       // the number of methods compiled.  For applications with a lot
       // classes the slow way is too slow.
       for (Dependencies::DepStream deps(nm); deps.next(); ) {
-        Klass* klass = deps.context_type();
-        if (klass == NULL) {
-          continue;  // ignore things like evol_method
+        if (deps.type() == Dependencies::call_site_target_value) {
+          // CallSite dependencies are managed on per-CallSite instance basis.
+          oop call_site = deps.argument_oop(0);
+          MethodHandles::add_dependent_nmethod(call_site, nm);
+        } else {
+          Klass* klass = deps.context_type();
+          if (klass == NULL) {
+            continue;  // ignore things like evol_method
+          }
+          // record this nmethod as dependent on this klass
+          InstanceKlass::cast(klass)->add_dependent_nmethod(nm);
         }
-
-        // record this nmethod as dependent on this klass
-        InstanceKlass::cast(klass)->add_dependent_nmethod(nm);
       }
       NOT_PRODUCT(nmethod_stats.note_nmethod(nm));
       if (PrintAssembly || CompilerOracle::has_option_string(method, "PrintAssembly")) {
@@ -1464,13 +1469,20 @@
   if (!has_flushed_dependencies()) {
     set_has_flushed_dependencies();
     for (Dependencies::DepStream deps(this); deps.next(); ) {
-      Klass* klass = deps.context_type();
-      if (klass == NULL)  continue;  // ignore things like evol_method
-
-      // During GC the is_alive closure is non-NULL, and is used to
-      // determine liveness of dependees that need to be updated.
-      if (is_alive == NULL || klass->is_loader_alive(is_alive)) {
-        InstanceKlass::cast(klass)->remove_dependent_nmethod(this);
+      if (deps.type() == Dependencies::call_site_target_value) {
+        // CallSite dependencies are managed on per-CallSite instance basis.
+        oop call_site = deps.argument_oop(0);
+        MethodHandles::remove_dependent_nmethod(call_site, this);
+      } else {
+        Klass* klass = deps.context_type();
+        if (klass == NULL) {
+          continue;  // ignore things like evol_method
+        }
+        // During GC the is_alive closure is non-NULL, and is used to
+        // determine liveness of dependees that need to be updated.
+        if (is_alive == NULL || klass->is_loader_alive(is_alive)) {
+          InstanceKlass::cast(klass)->remove_dependent_nmethod(this);
+        }
       }
     }
   }