8144874: Reimplement TraceClassResolution with Unified Logging.
authormockner
Wed, 23 Dec 2015 15:05:38 -0500
changeset 35219 b9ef87beb87c
parent 35217 ce4b5303a813
child 35220 a421e4a0f311
8144874: Reimplement TraceClassResolution with Unified Logging. Summary: TraceClassResolution reimplemented with classresolve tag. Reviewed-by: coleenp, dholmes, iklam, rprotacio
hotspot/src/share/vm/classfile/classFileParser.cpp
hotspot/src/share/vm/classfile/verificationType.cpp
hotspot/src/share/vm/classfile/verifier.cpp
hotspot/src/share/vm/classfile/verifier.hpp
hotspot/src/share/vm/logging/logTag.hpp
hotspot/src/share/vm/oops/constantPool.cpp
hotspot/src/share/vm/prims/jni.cpp
hotspot/src/share/vm/prims/jvm.cpp
hotspot/src/share/vm/runtime/arguments.cpp
hotspot/src/share/vm/runtime/globals.hpp
hotspot/src/share/vm/runtime/reflection.cpp
hotspot/test/runtime/verifier/TraceClassRes.java
--- a/hotspot/src/share/vm/classfile/classFileParser.cpp	Wed Dec 23 13:12:15 2015 +0300
+++ b/hotspot/src/share/vm/classfile/classFileParser.cpp	Wed Dec 23 15:05:38 2015 -0500
@@ -5369,12 +5369,12 @@
       }
     }
 
-    if (TraceClassResolution) {
+    if (log_is_enabled(Info, classresolve))  {
       ResourceMark rm;
       // print out the superclass.
       const char * from = ik->external_name();
       if (ik->java_super() != NULL) {
-        tty->print("RESOLVE %s %s (super)\n",
+        log_info(classresolve)("%s %s (super)",
                    from,
                    ik->java_super()->external_name());
       }
@@ -5385,7 +5385,7 @@
         for (int i = 0; i < length; i++) {
           const Klass* const k = local_interfaces->at(i);
           const char * to = k->external_name();
-          tty->print("RESOLVE %s %s (interface)\n", from, to);
+          log_info(classresolve)("%s %s (interface)", from, to);
         }
       }
     }
--- a/hotspot/src/share/vm/classfile/verificationType.cpp	Wed Dec 23 13:12:15 2015 +0300
+++ b/hotspot/src/share/vm/classfile/verificationType.cpp	Wed Dec 23 15:05:38 2015 -0500
@@ -61,7 +61,7 @@
     Klass* obj = SystemDictionary::resolve_or_fail(
         name(), Handle(THREAD, klass->class_loader()),
         Handle(THREAD, klass->protection_domain()), true, CHECK_false);
-    if (TraceClassResolution) {
+    if (log_is_enabled(Info, classresolve)) {
       Verifier::trace_class_resolution(obj, klass());
     }
 
@@ -80,7 +80,7 @@
       Klass* from_class = SystemDictionary::resolve_or_fail(
           from.name(), Handle(THREAD, klass->class_loader()),
           Handle(THREAD, klass->protection_domain()), true, CHECK_false);
-      if (TraceClassResolution) {
+      if (log_is_enabled(Info, classresolve)) {
         Verifier::trace_class_resolution(from_class, klass());
       }
       return InstanceKlass::cast(from_class)->is_subclass_of(this_class());
--- a/hotspot/src/share/vm/classfile/verifier.cpp	Wed Dec 23 13:12:15 2015 +0300
+++ b/hotspot/src/share/vm/classfile/verifier.cpp	Wed Dec 23 15:05:38 2015 -0500
@@ -106,9 +106,9 @@
   const char* resolve = resolve_class->external_name();
   // print in a single call to reduce interleaving between threads
   if (source_file != NULL) {
-    tty->print("RESOLVE %s %s %s (verification)\n", verify, resolve, source_file);
+    log_info(classresolve)("%s %s %s (verification)", verify, resolve, source_file);
   } else {
-    tty->print("RESOLVE %s %s (verification)\n", verify, resolve);
+    log_info(classresolve)("%s %s (verification)", verify, resolve);
   }
 }
 
@@ -206,7 +206,7 @@
     ResourceMark rm(THREAD);
     instanceKlassHandle kls =
       SystemDictionary::resolve_or_fail(exception_name, true, CHECK_false);
-    if (TraceClassResolution) {
+    if (log_is_enabled(Info, classresolve)) {
       Verifier::trace_class_resolution(kls(), klass());
     }
 
@@ -1992,7 +1992,7 @@
     name, Handle(THREAD, loader), Handle(THREAD, protection_domain),
     true, THREAD);
 
-  if (TraceClassResolution) {
+  if (log_is_enabled(Info, classresolve)) {
     instanceKlassHandle cur_class = current_class();
     Verifier::trace_class_resolution(kls, cur_class());
   }
--- a/hotspot/src/share/vm/classfile/verifier.hpp	Wed Dec 23 13:12:15 2015 +0300
+++ b/hotspot/src/share/vm/classfile/verifier.hpp	Wed Dec 23 15:05:38 2015 -0500
@@ -61,7 +61,7 @@
   // Relax certain verifier checks to enable some broken 1.1 apps to run on 1.2.
   static bool relax_verify_for(oop class_loader);
 
-  // Print output for -XX:+TraceClassResolution
+  // Print output for classresolve
   static void trace_class_resolution(Klass* resolve_class, InstanceKlass* verify_class);
 
  private:
--- a/hotspot/src/share/vm/logging/logTag.hpp	Wed Dec 23 13:12:15 2015 +0300
+++ b/hotspot/src/share/vm/logging/logTag.hpp	Wed Dec 23 15:05:38 2015 -0500
@@ -37,6 +37,7 @@
   LOG_TAG(bot) \
   LOG_TAG(census) \
   LOG_TAG(classhisto) \
+  LOG_TAG(classresolve) \
   LOG_TAG(classinit) \
   LOG_TAG(comp) \
   LOG_TAG(compaction) \
--- a/hotspot/src/share/vm/oops/constantPool.cpp	Wed Dec 23 13:12:15 2015 +0300
+++ b/hotspot/src/share/vm/oops/constantPool.cpp	Wed Dec 23 15:05:38 2015 -0500
@@ -204,11 +204,11 @@
   if (k() != this_cp->pool_holder()) {
     // only print something if the classes are different
     if (source_file != NULL) {
-      tty->print("RESOLVE %s %s %s:%d\n",
+      log_info(classresolve)("%s %s %s:%d",
                  this_cp->pool_holder()->external_name(),
                  k->external_name(), source_file, line_number);
     } else {
-      tty->print("RESOLVE %s %s\n",
+      log_info(classresolve)("%s %s",
                  this_cp->pool_holder()->external_name(),
                  k->external_name());
     }
@@ -277,7 +277,7 @@
   ClassLoaderData* this_key = this_cp->pool_holder()->class_loader_data();
   this_key->record_dependency(k(), CHECK_NULL); // Can throw OOM
 
-  if (TraceClassResolution && !k->is_array_klass()) {
+  if (log_is_enabled(Info, classresolve) && !k->is_array_klass()) {
     // skip resolving the constant pool so that this code gets
     // called the next time some bytecodes refer to this class.
     trace_class_resolution(this_cp, k);
--- a/hotspot/src/share/vm/prims/jni.cpp	Wed Dec 23 13:12:15 2015 +0300
+++ b/hotspot/src/share/vm/prims/jni.cpp	Wed Dec 23 15:05:38 2015 -0500
@@ -345,7 +345,7 @@
                                                    &st,
                                                    CHECK_NULL);
 
-  if (TraceClassResolution && k != NULL) {
+  if (log_is_enabled(Info, classresolve) && k != NULL) {
     trace_class_resolution(k);
   }
 
@@ -415,7 +415,7 @@
   result = find_class_from_class_loader(env, sym, true, loader,
                                         protection_domain, true, thread);
 
-  if (TraceClassResolution && result != NULL) {
+  if (log_is_enabled(Info, classresolve) && result != NULL) {
     trace_class_resolution(java_lang_Class::as_Klass(JNIHandles::resolve_non_null(result)));
   }
 
@@ -3277,7 +3277,7 @@
   TempNewSymbol sym = SymbolTable::new_symbol(name, CHECK_NULL);
   jclass result =  find_class_from_class_loader(env, sym, true, loader, protection_domain, true, CHECK_NULL);
 
-  if (TraceClassResolution && result != NULL) {
+  if (log_is_enabled(Info, classresolve) && result != NULL) {
     trace_class_resolution(java_lang_Class::as_Klass(JNIHandles::resolve_non_null(result)));
   }
   return result;
--- a/hotspot/src/share/vm/prims/jvm.cpp	Wed Dec 23 13:12:15 2015 +0300
+++ b/hotspot/src/share/vm/prims/jvm.cpp	Wed Dec 23 15:05:38 2015 -0500
@@ -206,9 +206,9 @@
       const char * to = to_class->external_name();
       // print in a single call to reduce interleaving between threads
       if (source_file != NULL) {
-        tty->print("RESOLVE %s %s %s:%d (%s)\n", from, to, source_file, line_number, trace);
+        log_info(classresolve)("%s %s %s:%d (%s)", from, to, source_file, line_number, trace);
       } else {
-        tty->print("RESOLVE %s %s (%s)\n", from, to, trace);
+        log_info(classresolve)("%s %s (%s)", from, to, trace);
       }
     }
   }
@@ -835,7 +835,7 @@
     return NULL;
   }
 
-  if (TraceClassResolution) {
+  if (log_is_enabled(Info, classresolve)) {
     trace_class_resolution(k);
   }
   return (jclass) JNIHandles::make_local(env, k->java_mirror());
@@ -872,7 +872,7 @@
   jclass result = find_class_from_class_loader(env, h_name, init, h_loader,
                                                h_prot, false, THREAD);
 
-  if (TraceClassResolution && result != NULL) {
+  if (log_is_enabled(Info, classresolve) && result != NULL) {
     trace_class_resolution(java_lang_Class::as_Klass(JNIHandles::resolve_non_null(result)));
   }
   return result;
@@ -902,7 +902,7 @@
   jclass result = find_class_from_class_loader(env, h_name, init, h_loader,
                                                h_prot, true, thread);
 
-  if (TraceClassResolution && result != NULL) {
+  if (log_is_enabled(Info, classresolve) && result != NULL) {
     // this function is generally only used for class loading during verification.
     ResourceMark rm;
     oop from_mirror = JNIHandles::resolve_non_null(from);
@@ -912,7 +912,7 @@
     oop mirror = JNIHandles::resolve_non_null(result);
     Klass* to_class = java_lang_Class::as_Klass(mirror);
     const char * to = to_class->external_name();
-    tty->print("RESOLVE %s %s (verification)\n", from_name, to);
+    log_info(classresolve)("%s %s (verification)", from_name, to);
   }
 
   return result;
@@ -980,7 +980,7 @@
                                                    &st,
                                                    CHECK_NULL);
 
-  if (TraceClassResolution && k != NULL) {
+  if (log_is_enabled(Info, classresolve) && k != NULL) {
     trace_class_resolution(k);
   }
 
--- a/hotspot/src/share/vm/runtime/arguments.cpp	Wed Dec 23 13:12:15 2015 +0300
+++ b/hotspot/src/share/vm/runtime/arguments.cpp	Wed Dec 23 15:05:38 2015 -0500
@@ -400,6 +400,8 @@
 };
 
 static AliasedFlag const aliased_jvm_logging_flags[] = {
+  { "-XX:+TraceClassResolution", "-Xlog:classresolve=info"},
+  { "-XX:-TraceClassResolution", "-Xlog:classresolve=off"},
   { "-XX:+TraceExceptions", "-Xlog:exceptions=info" },
   { "-XX:-TraceExceptions", "-Xlog:exceptions=off" },
   { "-XX:+TraceMonitorInflation", "-Xlog:monitorinflation=debug" },
--- a/hotspot/src/share/vm/runtime/globals.hpp	Wed Dec 23 13:12:15 2015 +0300
+++ b/hotspot/src/share/vm/runtime/globals.hpp	Wed Dec 23 15:05:38 2015 -0500
@@ -1496,9 +1496,6 @@
   develop(bool, TraceClearedExceptions, false,                              \
           "Print when an exception is forcibly cleared")                    \
                                                                             \
-  product(bool, TraceClassResolution, false,                                \
-          "Trace all constant pool resolutions (for debugging)")            \
-                                                                            \
   product(bool, TraceBiasedLocking, false,                                  \
           "Trace biased locking in JVM")                                    \
                                                                             \
--- a/hotspot/src/share/vm/runtime/reflection.cpp	Wed Dec 23 13:12:15 2015 +0300
+++ b/hotspot/src/share/vm/runtime/reflection.cpp	Wed Dec 23 15:05:38 2015 -0500
@@ -74,9 +74,9 @@
     const char * to = to_class->external_name();
     // print in a single call to reduce interleaving between threads
     if (source_file != NULL) {
-      tty->print("RESOLVE %s %s %s:%d (reflection)\n", from, to, source_file, line_number);
+      log_info(classresolve)("%s %s %s:%d (reflection)", from, to, source_file, line_number);
     } else {
-      tty->print("RESOLVE %s %s (reflection)\n", from, to);
+      log_info(classresolve)("%s %s (reflection)", from, to);
     }
   }
 }
@@ -599,7 +599,7 @@
                                                        Handle(THREAD, protection_domain),
                                                        true,
                                                        CHECK_NULL);
-    if (TraceClassResolution) {
+    if (log_is_enabled(Info, classresolve)) {
       trace_class_resolution(k);
     }
     return k->java_mirror();
@@ -654,7 +654,7 @@
                                       Handle(THREAD, k->protection_domain()),
                                       true, CHECK_(Handle()));
 
-  if (TraceClassResolution) {
+  if (log_is_enabled(Info, classresolve)) {
     trace_class_resolution(result);
   }
 
--- a/hotspot/test/runtime/verifier/TraceClassRes.java	Wed Dec 23 13:12:15 2015 +0300
+++ b/hotspot/test/runtime/verifier/TraceClassRes.java	Wed Dec 23 15:05:38 2015 -0500
@@ -38,7 +38,7 @@
         "-XX:+TraceClassResolution", "-verify", "-Xshare:off", "-version");
 
     OutputAnalyzer output = new OutputAnalyzer(pb.start());
-    output.shouldContain("RESOLVE java.lang.ClassLoader java.lang.Throwable ClassLoader.java (verification)");
+    output.shouldContain("[classresolve] java.lang.ClassLoader java.lang.Throwable ClassLoader.java (verification)");
     output.shouldHaveExitValue(0);
   }
 }