src/share/vm/oops/instanceKlass.cpp

Print this page
rev 9502 : imported patch 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"


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


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