src/share/vm/classfile/classLoaderData.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File
*** old/src/share/vm/classfile/classLoaderData.cpp	Thu Jan 28 14:14:16 2016
--- new/src/share/vm/classfile/classLoaderData.cpp	Thu Jan 28 14:14:16 2016

*** 1,7 **** --- 1,7 ---- /* ! * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. ! * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation.
*** 52,67 **** --- 52,69 ---- #include "classfile/javaClasses.hpp" #include "classfile/metadataOnStackMark.hpp" #include "classfile/systemDictionary.hpp" #include "code/codeCache.hpp" #include "gc/shared/gcLocker.hpp" + #include "logging/log.hpp" #include "memory/metadataFactory.hpp" #include "memory/metaspaceShared.hpp" #include "memory/oopFactory.hpp" #include "oops/objArrayOop.inline.hpp" #include "oops/oop.inline.hpp" #include "runtime/atomic.inline.hpp" + #include "runtime/javaCalls.hpp" #include "runtime/jniHandles.hpp" #include "runtime/mutex.hpp" #include "runtime/safepoint.hpp" #include "runtime/synchronizer.hpp" #include "utilities/growableArray.hpp"
*** 284,296 **** --- 286,298 ---- OrderAccess::storestore(); // link the new item into the list _klasses = k; } - if (publicize && TraceClassLoaderData && Verbose && k->class_loader_data() != NULL) { ResourceMark rm; ! tty->print_cr("[TraceClassLoaderData] Adding k: " PTR_FORMAT " %s to CLD: " ! log_trace(classloaderdata)("Adding k: " PTR_FORMAT " %s to CLD: " PTR_FORMAT " loader: " PTR_FORMAT " %s", p2i(k), k->external_name(), p2i(k->class_loader_data()), p2i((void *)k->class_loader()),
*** 324,342 **** --- 326,345 ---- _unloading = true; // Tell serviceability tools these classes are unloading classes_do(InstanceKlass::notify_unload_class); ! if (TraceClassLoaderData) { ! if (log_is_enabled(Debug, classloaderdata)) { ResourceMark rm; ! tty->print("[ClassLoaderData: unload loader data " INTPTR_FORMAT, p2i(this)); tty->print(" for instance " INTPTR_FORMAT " of %s", p2i((void *)class_loader()), ! outputStream* log = LogHandle(classloaderdata)::debug_stream(); + log->print(": unload loader data " INTPTR_FORMAT, p2i(this)); + log->print(" for instance " INTPTR_FORMAT " of %s", p2i((void *)class_loader()), loader_name()); if (is_anonymous()) { ! tty->print(" for anonymous class " INTPTR_FORMAT " ", p2i(_klasses)); ! log->print(" for anonymous class " INTPTR_FORMAT " ", p2i(_klasses)); } ! tty->print_cr("]"); ! log->cr(); } } oop ClassLoaderData::keep_alive_object() const { assert(!keep_alive(), "Don't use with CLDs that are artificially kept alive");
*** 406,422 **** --- 409,425 ---- } if (this == the_null_class_loader_data()) { assert (class_loader() == NULL, "Must be"); set_metaspace(new Metaspace(_metaspace_lock, Metaspace::BootMetaspaceType)); } else if (is_anonymous()) { - if (TraceClassLoaderData && Verbose && class_loader() != NULL) { ! tty->print_cr("is_anonymous: %s", class_loader()->klass()->internal_name()); ! log_trace(classloaderdata)("is_anonymous: %s", class_loader()->klass()->internal_name()); } set_metaspace(new Metaspace(_metaspace_lock, Metaspace::AnonymousMetaspaceType)); } else if (class_loader()->is_a(SystemDictionary::reflect_DelegatingClassLoader_klass())) { - if (TraceClassLoaderData && Verbose && class_loader() != NULL) { ! tty->print_cr("is_reflection: %s", class_loader()->klass()->internal_name()); ! log_trace(classloaderdata)("is_reflection: %s", class_loader()->klass()->internal_name()); } set_metaspace(new Metaspace(_metaspace_lock, Metaspace::ReflectionMetaspaceType)); } else { set_metaspace(new Metaspace(_metaspace_lock, Metaspace::StandardMetaspaceType)); }
*** 599,623 **** --- 602,652 ---- do { cld->set_next(next); ClassLoaderData* exchanged = (ClassLoaderData*)Atomic::cmpxchg_ptr(cld, list_head, next); if (exchanged == next) { ! if (TraceClassLoaderData) { ResourceMark rm; ! tty->print("[ClassLoaderData: "); tty->print("create class loader data " INTPTR_FORMAT, p2i(cld)); tty->print(" for instance " INTPTR_FORMAT " of %s", p2i((void *)cld->class_loader()), cld->loader_name()); tty->print_cr("]"); ! if (log_is_enabled(Debug, classloaderdata)) { + PauseNoSafepointVerifier pnsv(&no_safepoints); // Need safe points for JavaCalls::call_virtual ! log_creation(loader, cld, CHECK_NULL); } return cld; } next = exchanged; } while (true); + } + + void ClassLoaderDataGraph::log_creation(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); + KlassHandle spec_klass(THREAD, SystemDictionary::ClassLoader_klass()); + JavaCalls::call_virtual(&result, + loader, + spec_klass, + vmSymbols::toString_name(), + vmSymbols::void_string_signature(), + CHECK); + assert(result.get_type() == T_OBJECT, "just checking"); + string = (oop)result.get_jobject(); + } + ResourceMark rm; + outputStream* log = LogHandle(classloaderdata)::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()), + cld->loader_name()); + + if (string.not_null()) { + log->print(": "); + java_lang_String::print(string(), log); + } + log->cr(); } + void ClassLoaderDataGraph::oops_do(OopClosure* f, KlassClosure* klass_closure, bool must_claim) { for (ClassLoaderData* cld = _head; cld != NULL; cld = cld->next()) { cld->oops_do(f, klass_closure, must_claim); } }
*** 707,720 **** --- 736,750 ---- ClassLoaderData* curr = _head; while (curr != _saved_head) { if (!curr->claimed()) { array->push(curr); ! if (TraceClassLoaderData) { ! tty->print("[ClassLoaderData] found new CLD: "); ! curr->print_value_on(tty); ! tty->cr(); ! if (log_is_enabled(Debug, classloaderdata)) { ! outputStream* log = LogHandle(classloaderdata)::debug_stream(); ! log->print("found new CLD: "); ! curr->print_value_on(log); + log->cr(); } } curr = curr->_next; }

src/share/vm/classfile/classLoaderData.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File