1 /*
2 * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
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/classFileParser.hpp"
27 #include "classfile/javaClasses.hpp"
28 #include "classfile/systemDictionary.hpp"
29 #include "classfile/verifier.hpp"
30 #include "classfile/vmSymbols.hpp"
31 #include "code/dependencyContext.hpp"
32 #include "compiler/compileBroker.hpp"
33 #include "gc/shared/collectedHeap.inline.hpp"
34 #include "gc/shared/specialized_oop_closures.hpp"
35 #include "interpreter/oopMapCache.hpp"
36 #include "interpreter/rewriter.hpp"
37 #include "jvmtifiles/jvmti.h"
38 #include "memory/heapInspection.hpp"
39 #include "memory/iterator.inline.hpp"
40 #include "memory/metadataFactory.hpp"
41 #include "memory/oopFactory.hpp"
42 #include "oops/fieldStreams.hpp"
43 #include "oops/instanceClassLoaderKlass.hpp"
44 #include "oops/instanceKlass.inline.hpp"
45 #include "oops/instanceMirrorKlass.hpp"
46 #include "oops/instanceOop.hpp"
47 #include "oops/klass.inline.hpp"
48 #include "oops/method.hpp"
49 #include "oops/oop.inline.hpp"
50 #include "oops/symbol.hpp"
51 #include "prims/jvmtiExport.hpp"
52 #include "prims/jvmtiRedefineClasses.hpp"
53 #include "prims/jvmtiRedefineClassesTrace.hpp"
54 #include "prims/jvmtiThreadState.hpp"
55 #include "prims/methodComparator.hpp"
56 #include "runtime/atomic.inline.hpp"
57 #include "runtime/fieldDescriptor.hpp"
2885 oop vmentry = java_lang_invoke_LambdaForm::vmentry(obj);
2886 if (vmentry != NULL) {
2887 st->print(" => ");
2888 vmentry->print_value_on(st);
2889 }
2890 } else if (this == SystemDictionary::MemberName_klass()) {
2891 Metadata* vmtarget = java_lang_invoke_MemberName::vmtarget(obj);
2892 if (vmtarget != NULL) {
2893 st->print(" = ");
2894 vmtarget->print_value_on(st);
2895 } else {
2896 java_lang_invoke_MemberName::clazz(obj)->print_value_on(st);
2897 st->print(".");
2898 java_lang_invoke_MemberName::name(obj)->print_value_on(st);
2899 }
2900 }
2901 }
2902
2903 const char* InstanceKlass::internal_name() const {
2904 return external_name();
2905 }
2906
2907 #if INCLUDE_SERVICES
2908 // Size Statistics
2909 void InstanceKlass::collect_statistics(KlassSizeStats *sz) const {
2910 Klass::collect_statistics(sz);
2911
2912 sz->_inst_size = HeapWordSize * size_helper();
2913 sz->_vtab_bytes = HeapWordSize * align_object_offset(vtable_length());
2914 sz->_itab_bytes = HeapWordSize * align_object_offset(itable_length());
2915 sz->_nonstatic_oopmap_bytes = HeapWordSize *
2916 ((is_interface() || is_anonymous()) ?
2917 align_object_offset(nonstatic_oop_map_size()) :
2918 nonstatic_oop_map_size());
2919
2920 int n = 0;
2921 n += (sz->_methods_array_bytes = sz->count_array(methods()));
2922 n += (sz->_method_ordering_bytes = sz->count_array(method_ordering()));
2923 n += (sz->_local_interfaces_bytes = sz->count_array(local_interfaces()));
2924 n += (sz->_transitive_interfaces_bytes = sz->count_array(transitive_interfaces()));
|
1 /*
2 * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
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/classFileParser.hpp"
27 #include "classfile/javaClasses.hpp"
28 #include "classfile/systemDictionary.hpp"
29 #include "classfile/verifier.hpp"
30 #include "classfile/vmSymbols.hpp"
31 #include "code/dependencyContext.hpp"
32 #include "compiler/compileBroker.hpp"
33 #include "gc/shared/collectedHeap.inline.hpp"
34 #include "gc/shared/specialized_oop_closures.hpp"
35 #include "interpreter/oopMapCache.hpp"
36 #include "interpreter/rewriter.hpp"
37 #include "jvmtifiles/jvmti.h"
38 #include "logging/log.hpp"
39 #include "memory/heapInspection.hpp"
40 #include "memory/iterator.inline.hpp"
41 #include "memory/metadataFactory.hpp"
42 #include "memory/oopFactory.hpp"
43 #include "oops/fieldStreams.hpp"
44 #include "oops/instanceClassLoaderKlass.hpp"
45 #include "oops/instanceKlass.inline.hpp"
46 #include "oops/instanceMirrorKlass.hpp"
47 #include "oops/instanceOop.hpp"
48 #include "oops/klass.inline.hpp"
49 #include "oops/method.hpp"
50 #include "oops/oop.inline.hpp"
51 #include "oops/symbol.hpp"
52 #include "prims/jvmtiExport.hpp"
53 #include "prims/jvmtiRedefineClasses.hpp"
54 #include "prims/jvmtiRedefineClassesTrace.hpp"
55 #include "prims/jvmtiThreadState.hpp"
56 #include "prims/methodComparator.hpp"
57 #include "runtime/atomic.inline.hpp"
58 #include "runtime/fieldDescriptor.hpp"
2886 oop vmentry = java_lang_invoke_LambdaForm::vmentry(obj);
2887 if (vmentry != NULL) {
2888 st->print(" => ");
2889 vmentry->print_value_on(st);
2890 }
2891 } else if (this == SystemDictionary::MemberName_klass()) {
2892 Metadata* vmtarget = java_lang_invoke_MemberName::vmtarget(obj);
2893 if (vmtarget != NULL) {
2894 st->print(" = ");
2895 vmtarget->print_value_on(st);
2896 } else {
2897 java_lang_invoke_MemberName::clazz(obj)->print_value_on(st);
2898 st->print(".");
2899 java_lang_invoke_MemberName::name(obj)->print_value_on(st);
2900 }
2901 }
2902 }
2903
2904 const char* InstanceKlass::internal_name() const {
2905 return external_name();
2906 }
2907
2908 void InstanceKlass::print_loading_log(LogLevel::type type, ClassLoaderData* loader_data, const ClassFileStream* cfs) const {
2909 ResourceMark rm;
2910 outputStream* log;
2911
2912 assert(type == LogLevel::Info || type == LogLevel::Debug, "sanity");
2913
2914 if (type == LogLevel::Info) {
2915 log = LogHandle(classload)::info_stream();
2916 } else {
2917 assert(type == LogLevel::Debug, "print_loading_log supports only Debug and Info levels");
2918 log = LogHandle(classload)::debug_stream();
2919 }
2920
2921 // Name and class hierarchy info
2922 log->print("%s", external_name());
2923
2924 // Source
2925 if (cfs != NULL) {
2926 if (cfs->source() != NULL) {
2927 log->print(" source: %s", cfs->source());
2928 } else if (loader_data == ClassLoaderData::the_null_class_loader_data()) {
2929 Thread* THREAD = Thread::current();
2930 Klass* caller =
2931 THREAD->is_Java_thread()
2932 ? ((JavaThread*)THREAD)->security_get_caller_class(1)
2933 : NULL;
2934 // caller can be NULL, for example, during a JVMTI VM_Init hook
2935 if (caller != NULL) {
2936 log->print(" source: instance of %s", caller->external_name());
2937 } else {
2938 // source is unknown
2939 }
2940 } else {
2941 Handle class_loader(loader_data->class_loader());
2942 log->print(" source: %s", class_loader->klass()->external_name());
2943 }
2944 } else {
2945 log->print(" source: shared objects file");
2946 }
2947
2948 if (type == LogLevel::Debug) {
2949 // Class hierarchy info
2950 log->print(" klass: " INTPTR_FORMAT " super: " INTPTR_FORMAT,
2951 p2i(this), p2i(superklass()));
2952
2953 if (local_interfaces() != NULL && local_interfaces()->length() > 0) {
2954 log->print(" interfaces:");
2955 int length = local_interfaces()->length();
2956 for (int i = 0; i < length; i++) {
2957 log->print(" " INTPTR_FORMAT, p2i(InstanceKlass::cast(local_interfaces()->at(i))));
2958 }
2959 }
2960
2961 // Class loader
2962 log->print(" loader: [");
2963 loader_data->print_value_on(log);
2964 log->print("]");
2965
2966 // Classfile checksum
2967 if (cfs) {
2968 log->print(" bytes: %d checksum: %08x", cfs->length(), ClassLoader::crc32(0, (const char*)cfs->buffer(), cfs->length()));
2969 }
2970 }
2971 log->cr();
2972 }
2973
2974 #if INCLUDE_SERVICES
2975 // Size Statistics
2976 void InstanceKlass::collect_statistics(KlassSizeStats *sz) const {
2977 Klass::collect_statistics(sz);
2978
2979 sz->_inst_size = HeapWordSize * size_helper();
2980 sz->_vtab_bytes = HeapWordSize * align_object_offset(vtable_length());
2981 sz->_itab_bytes = HeapWordSize * align_object_offset(itable_length());
2982 sz->_nonstatic_oopmap_bytes = HeapWordSize *
2983 ((is_interface() || is_anonymous()) ?
2984 align_object_offset(nonstatic_oop_map_size()) :
2985 nonstatic_oop_map_size());
2986
2987 int n = 0;
2988 n += (sz->_methods_array_bytes = sz->count_array(methods()));
2989 n += (sz->_method_ordering_bytes = sz->count_array(method_ordering()));
2990 n += (sz->_local_interfaces_bytes = sz->count_array(local_interfaces()));
2991 n += (sz->_transitive_interfaces_bytes = sz->count_array(transitive_interfaces()));
|