src/share/vm/oops/instanceKlass.cpp

Print this page
rev 9245 : [mq]: class_loading_log


  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "classfile/javaClasses.hpp"
  27 #include "classfile/systemDictionary.hpp"
  28 #include "classfile/verifier.hpp"
  29 #include "classfile/vmSymbols.hpp"
  30 #include "compiler/compileBroker.hpp"
  31 #include "gc/shared/collectedHeap.inline.hpp"
  32 #include "gc/shared/specialized_oop_closures.hpp"
  33 #include "interpreter/oopMapCache.hpp"
  34 #include "interpreter/rewriter.hpp"
  35 #include "jvmtifiles/jvmti.h"

  36 #include "memory/heapInspection.hpp"
  37 #include "memory/iterator.inline.hpp"
  38 #include "memory/metadataFactory.hpp"
  39 #include "memory/oopFactory.hpp"
  40 #include "oops/fieldStreams.hpp"
  41 #include "oops/instanceClassLoaderKlass.hpp"
  42 #include "oops/instanceKlass.inline.hpp"
  43 #include "oops/instanceMirrorKlass.hpp"
  44 #include "oops/instanceOop.hpp"
  45 #include "oops/klass.inline.hpp"
  46 #include "oops/method.hpp"
  47 #include "oops/oop.inline.hpp"
  48 #include "oops/symbol.hpp"
  49 #include "prims/jvmtiExport.hpp"
  50 #include "prims/jvmtiRedefineClasses.hpp"
  51 #include "prims/jvmtiRedefineClassesTrace.hpp"
  52 #include "prims/jvmtiThreadState.hpp"
  53 #include "prims/methodComparator.hpp"
  54 #include "runtime/atomic.inline.hpp"
  55 #include "runtime/fieldDescriptor.hpp"


3011     oop vmentry = java_lang_invoke_LambdaForm::vmentry(obj);
3012     if (vmentry != NULL) {
3013       st->print(" => ");
3014       vmentry->print_value_on(st);
3015     }
3016   } else if (this == SystemDictionary::MemberName_klass()) {
3017     Metadata* vmtarget = java_lang_invoke_MemberName::vmtarget(obj);
3018     if (vmtarget != NULL) {
3019       st->print(" = ");
3020       vmtarget->print_value_on(st);
3021     } else {
3022       java_lang_invoke_MemberName::clazz(obj)->print_value_on(st);
3023       st->print(".");
3024       java_lang_invoke_MemberName::name(obj)->print_value_on(st);
3025     }
3026   }
3027 }
3028 
3029 const char* InstanceKlass::internal_name() const {
3030   return external_name();


































































3031 }
3032 
3033 #if INCLUDE_SERVICES
3034 // Size Statistics
3035 void InstanceKlass::collect_statistics(KlassSizeStats *sz) const {
3036   Klass::collect_statistics(sz);
3037 
3038   sz->_inst_size  = HeapWordSize * size_helper();
3039   sz->_vtab_bytes = HeapWordSize * align_object_offset(vtable_length());
3040   sz->_itab_bytes = HeapWordSize * align_object_offset(itable_length());
3041   sz->_nonstatic_oopmap_bytes = HeapWordSize *
3042         ((is_interface() || is_anonymous()) ?
3043          align_object_offset(nonstatic_oop_map_size()) :
3044          nonstatic_oop_map_size());
3045 
3046   int n = 0;
3047   n += (sz->_methods_array_bytes         = sz->count_array(methods()));
3048   n += (sz->_method_ordering_bytes       = sz->count_array(method_ordering()));
3049   n += (sz->_local_interfaces_bytes      = sz->count_array(local_interfaces()));
3050   n += (sz->_transitive_interfaces_bytes = sz->count_array(transitive_interfaces()));




  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "classfile/javaClasses.hpp"
  27 #include "classfile/systemDictionary.hpp"
  28 #include "classfile/verifier.hpp"
  29 #include "classfile/vmSymbols.hpp"
  30 #include "compiler/compileBroker.hpp"
  31 #include "gc/shared/collectedHeap.inline.hpp"
  32 #include "gc/shared/specialized_oop_closures.hpp"
  33 #include "interpreter/oopMapCache.hpp"
  34 #include "interpreter/rewriter.hpp"
  35 #include "jvmtifiles/jvmti.h"
  36 #include "logging/log.hpp"
  37 #include "memory/heapInspection.hpp"
  38 #include "memory/iterator.inline.hpp"
  39 #include "memory/metadataFactory.hpp"
  40 #include "memory/oopFactory.hpp"
  41 #include "oops/fieldStreams.hpp"
  42 #include "oops/instanceClassLoaderKlass.hpp"
  43 #include "oops/instanceKlass.inline.hpp"
  44 #include "oops/instanceMirrorKlass.hpp"
  45 #include "oops/instanceOop.hpp"
  46 #include "oops/klass.inline.hpp"
  47 #include "oops/method.hpp"
  48 #include "oops/oop.inline.hpp"
  49 #include "oops/symbol.hpp"
  50 #include "prims/jvmtiExport.hpp"
  51 #include "prims/jvmtiRedefineClasses.hpp"
  52 #include "prims/jvmtiRedefineClassesTrace.hpp"
  53 #include "prims/jvmtiThreadState.hpp"
  54 #include "prims/methodComparator.hpp"
  55 #include "runtime/atomic.inline.hpp"
  56 #include "runtime/fieldDescriptor.hpp"


3012     oop vmentry = java_lang_invoke_LambdaForm::vmentry(obj);
3013     if (vmentry != NULL) {
3014       st->print(" => ");
3015       vmentry->print_value_on(st);
3016     }
3017   } else if (this == SystemDictionary::MemberName_klass()) {
3018     Metadata* vmtarget = java_lang_invoke_MemberName::vmtarget(obj);
3019     if (vmtarget != NULL) {
3020       st->print(" = ");
3021       vmtarget->print_value_on(st);
3022     } else {
3023       java_lang_invoke_MemberName::clazz(obj)->print_value_on(st);
3024       st->print(".");
3025       java_lang_invoke_MemberName::name(obj)->print_value_on(st);
3026     }
3027   }
3028 }
3029 
3030 const char* InstanceKlass::internal_name() const {
3031   return external_name();
3032 }
3033 
3034 void InstanceKlass::print_loading_log(LogLevel::type type, ClassLoaderData* loader_data, ClassFileStream* cfs) const {
3035   ResourceMark rm;
3036   outputStream* log;
3037 
3038   assert(type == LogLevel::Debug || type == LogLevel::Trace, "sanity");
3039 
3040   if (type == LogLevel::Debug) {
3041     log = LogHandle(classload)::debug_stream();
3042   } else {
3043     assert(type == LogLevel::Trace, "print_loading_log supports only Debug and Trace levels");
3044     log = LogHandle(classload)::trace_stream();
3045   }
3046 
3047   // Name and class hierarchy info
3048   log->print("%s", external_name());
3049 
3050   // Source
3051   if (cfs != NULL) {
3052     if (cfs->source() != NULL) {
3053       log->print(" source: %s", cfs->source());
3054     } else if (loader_data == ClassLoaderData::the_null_class_loader_data()) {
3055       Thread* THREAD = Thread::current();
3056       Klass* caller =
3057             THREAD->is_Java_thread()
3058                 ? ((JavaThread*)THREAD)->security_get_caller_class(1)
3059                 : NULL;
3060       // caller can be NULL, for example, during a JVMTI VM_Init hook
3061       if (caller != NULL) {
3062         tty->print(" source: instance of %s", caller->external_name());
3063       } else {
3064         // source is unknown
3065       }
3066     } else {
3067       Handle class_loader(loader_data->class_loader());
3068       tty->print(" source: %s", class_loader->klass()->external_name());
3069     }
3070   } else {
3071     log->print(" source: shared objects file");
3072   }
3073 
3074   if (type == LogLevel::Trace) {
3075     // Class hierarchy info
3076     log->print(" klass: " INTPTR_FORMAT " super: " INTPTR_FORMAT,
3077                p2i(this),  p2i(superklass()));
3078 
3079     if (local_interfaces() != NULL && local_interfaces()->length() > 0) {
3080       log->print(" interfaces:");
3081       int length = local_interfaces()->length();
3082       for (int i = 0; i < length; i++) {
3083         log->print(" " INTPTR_FORMAT, p2i(InstanceKlass::cast(local_interfaces()->at(i))));
3084       }
3085     }
3086 
3087     // Class loader
3088     log->print(" loader: [");
3089     loader_data->print_value_on(log);
3090     log->print("]");
3091 
3092     // Classfile checksum
3093     if (cfs) {
3094       log->print(" bytes: %d checksum: %08x", cfs->length(), ClassLoader::crc32(0, (const char*)cfs->buffer(), cfs->length()));
3095     }
3096   }
3097   log->cr();
3098 }
3099 
3100 #if INCLUDE_SERVICES
3101 // Size Statistics
3102 void InstanceKlass::collect_statistics(KlassSizeStats *sz) const {
3103   Klass::collect_statistics(sz);
3104 
3105   sz->_inst_size  = HeapWordSize * size_helper();
3106   sz->_vtab_bytes = HeapWordSize * align_object_offset(vtable_length());
3107   sz->_itab_bytes = HeapWordSize * align_object_offset(itable_length());
3108   sz->_nonstatic_oopmap_bytes = HeapWordSize *
3109         ((is_interface() || is_anonymous()) ?
3110          align_object_offset(nonstatic_oop_map_size()) :
3111          nonstatic_oop_map_size());
3112 
3113   int n = 0;
3114   n += (sz->_methods_array_bytes         = sz->count_array(methods()));
3115   n += (sz->_method_ordering_bytes       = sz->count_array(method_ordering()));
3116   n += (sz->_local_interfaces_bytes      = sz->count_array(local_interfaces()));
3117   n += (sz->_transitive_interfaces_bytes = sz->count_array(transitive_interfaces()));