diff src/share/vm/code/codeCache.cpp @ 14909:4ca6dc0799b6

Backout jdk9 merge
author Gilles Duboscq <duboscq@ssw.jku.at>
date Tue, 01 Apr 2014 13:57:07 +0200
parents d8041d695d19
children 52b4284cb496
line wrap: on
line diff
--- a/src/share/vm/code/codeCache.cpp	Tue Apr 01 14:09:03 2014 +0200
+++ b/src/share/vm/code/codeCache.cpp	Tue Apr 01 13:57:07 2014 +0200
@@ -595,11 +595,21 @@
   }
 }
 
-// Keeps track of time spent for checking dependencies
-NOT_PRODUCT(static elapsedTimer dependentCheckTime;)
+#ifndef PRODUCT
+// used to keep track of how much time is spent in mark_for_deoptimization
+static elapsedTimer dependentCheckTime;
+static int dependentCheckCount = 0;
+#endif // PRODUCT
+
 
 int CodeCache::mark_for_deoptimization(DepChange& changes) {
   MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
+
+#ifndef PRODUCT
+  dependentCheckTime.start();
+  dependentCheckCount++;
+#endif // PRODUCT
+
   int number_of_marked_CodeBlobs = 0;
 
   // search the hierarchy looking for nmethods which are affected by the loading of this class
@@ -607,23 +617,32 @@
   // then search the interfaces this class implements looking for nmethods
   // which might be dependent of the fact that an interface only had one
   // implementor.
-  // nmethod::check_all_dependencies works only correctly, if no safepoint
-  // can happen
-  No_Safepoint_Verifier nsv;
-  for (DepChange::ContextStream str(changes, nsv); str.next(); ) {
-    Klass* d = str.klass();
-    number_of_marked_CodeBlobs += InstanceKlass::cast(d)->mark_dependent_nmethods(changes);
+
+  { No_Safepoint_Verifier nsv;
+    for (DepChange::ContextStream str(changes, nsv); str.next(); ) {
+      Klass* d = str.klass();
+      number_of_marked_CodeBlobs += InstanceKlass::cast(d)->mark_dependent_nmethods(changes);
+    }
+  }
+
+  if (VerifyDependencies) {
+    // Turn off dependency tracing while actually testing deps.
+    NOT_PRODUCT( FlagSetting fs(TraceDependencies, false) );
+    FOR_ALL_ALIVE_NMETHODS(nm) {
+      if (!nm->is_marked_for_deoptimization() &&
+          nm->check_all_dependencies()) {
+        ResourceMark rm;
+        tty->print_cr("Should have been marked for deoptimization:");
+        changes.print();
+        nm->print();
+        nm->print_dependencies();
+      }
+    }
   }
 
 #ifndef PRODUCT
-  if (VerifyDependencies) {
-    // Object pointers are used as unique identifiers for dependency arguments. This
-    // is only possible if no safepoint, i.e., GC occurs during the verification code.
-    dependentCheckTime.start();
-    nmethod::check_all_dependencies(changes);
-    dependentCheckTime.stop();
-  }
-#endif
+  dependentCheckTime.stop();
+#endif // PRODUCT
 
   return number_of_marked_CodeBlobs;
 }
@@ -880,7 +899,9 @@
   }
 
   tty->print_cr("CodeCache:");
-  tty->print_cr("nmethod dependency checking time %fs", dependentCheckTime.seconds());
+
+  tty->print_cr("nmethod dependency checking time %f", dependentCheckTime.seconds(),
+                dependentCheckTime.seconds() / dependentCheckCount);
 
   if (!live.is_empty()) {
     live.print("live");