< prev index next >

src/share/vm/classfile/classLoaderData.cpp

Print this page
rev 13113 : imported patch 8181917-refactor-ul-logstream

@@ -55,10 +55,11 @@
 #include "classfile/packageEntry.hpp"
 #include "classfile/systemDictionary.hpp"
 #include "code/codeCache.hpp"
 #include "gc/shared/gcLocker.hpp"
 #include "logging/log.hpp"
+#include "logging/logStream.hpp"
 #include "memory/metadataFactory.hpp"
 #include "memory/metaspaceShared.hpp"
 #include "memory/oopFactory.hpp"
 #include "memory/resourceArea.hpp"
 #include "oops/objArrayOop.inline.hpp"

@@ -474,20 +475,21 @@
   _unloading = true;
 
   // Tell serviceability tools these classes are unloading
   classes_do(InstanceKlass::notify_unload_class);
 
-  if (log_is_enabled(Debug, class, loader, data)) {
+  LogTarget(Debug, class, loader, data) lt;
+  if (lt.is_enabled()) {
     ResourceMark rm;
-    outputStream* log = Log(class, loader, data)::debug_stream();
-    log->print(": unload loader data " INTPTR_FORMAT, p2i(this));
-    log->print(" for instance " INTPTR_FORMAT " of %s", p2i((void *)class_loader()),
+    LogStream ls(lt);
+    ls.print(": unload loader data " INTPTR_FORMAT, p2i(this));
+    ls.print(" for instance " INTPTR_FORMAT " of %s", p2i((void *)class_loader()),
                loader_name());
     if (is_anonymous()) {
-      log->print(" for anonymous class  " INTPTR_FORMAT " ", p2i(_klasses));
+      ls.print(" for anonymous class  " INTPTR_FORMAT " ", p2i(_klasses));
     }
-    log->cr();
+    ls.cr();
   }
 
   // In some rare cases items added to this list will not be freed elsewhere.
   // To keep it simple, just free everything in it here.
   free_deallocate_list();

@@ -801,21 +803,23 @@
 
   do {
     cld->set_next(next);
     ClassLoaderData* exchanged = (ClassLoaderData*)Atomic::cmpxchg_ptr(cld, list_head, next);
     if (exchanged == next) {
-      if (log_is_enabled(Debug, class, loader, data)) {
+      LogTarget(Debug, class, loader, data) lt;
+      if (lt.is_enabled()) {
        PauseNoSafepointVerifier pnsv(&no_safepoints); // Need safe points for JavaCalls::call_virtual
-       log_creation(loader, cld, CHECK_NULL);
+       LogStream ls(lt);
+       print_creation(&ls, loader, cld, CHECK_NULL);
       }
       return cld;
     }
     next = exchanged;
   } while (true);
 }
 
-void ClassLoaderDataGraph::log_creation(Handle loader, ClassLoaderData* cld, TRAPS) {
+void ClassLoaderDataGraph::print_creation(outputStream* out, Handle loader, ClassLoaderData* cld, TRAPS) {
   Handle string;
   if (loader.not_null()) {
     // Include the result of loader.toString() in the output. This allows
     // the user of the log to identify the class loader instance.
     JavaValue result(T_OBJECT);

@@ -829,20 +833,19 @@
     assert(result.get_type() == T_OBJECT, "just checking");
     string = Handle(THREAD, (oop)result.get_jobject());
   }
 
   ResourceMark rm;
-  outputStream* log = Log(class, loader, data)::debug_stream();
-  log->print("create class loader data " INTPTR_FORMAT, p2i(cld));
-  log->print(" for instance " INTPTR_FORMAT " of %s", p2i((void *)cld->class_loader()),
+  out->print("create class loader data " INTPTR_FORMAT, p2i(cld));
+  out->print(" for instance " INTPTR_FORMAT " of %s", p2i((void *)cld->class_loader()),
              cld->loader_name());
 
   if (string.not_null()) {
-    log->print(": ");
-    java_lang_String::print(string(), log);
+    out->print(": ");
+    java_lang_String::print(string(), out);
   }
-  log->cr();
+  out->cr();
 }
 
 
 void ClassLoaderDataGraph::oops_do(OopClosure* f, KlassClosure* klass_closure, bool must_claim) {
   for (ClassLoaderData* cld = _head; cld != NULL; cld = cld->next()) {

@@ -979,16 +982,16 @@
   // The CLDs in [_head, _saved_head] were all added during last call to remember_new_clds(true);
   ClassLoaderData* curr = _head;
   while (curr != _saved_head) {
     if (!curr->claimed()) {
       array->push(curr);
-
-      if (log_is_enabled(Debug, class, loader, data)) {
-        outputStream* log = Log(class, loader, data)::debug_stream();
-        log->print("found new CLD: ");
-        curr->print_value_on(log);
-        log->cr();
+      LogTarget(Debug, class, loader, data) lt;
+      if (lt.is_enabled()) {
+        LogStream ls(lt);
+        ls.print("found new CLD: ");
+        curr->print_value_on(&ls);
+        ls.cr();
       }
     }
 
     curr = curr->_next;
   }
< prev index next >