src/share/vm/services/classLoadingService.hpp

Mon, 12 Nov 2012 16:15:05 -0500

author
hseigel
date
Mon, 12 Nov 2012 16:15:05 -0500
changeset 4278
070d523b96a7
parent 4165
fb19af007ffc
child 4542
db9981fd3124
permissions
-rw-r--r--

8001471: Klass::cast() does nothing
Summary: Remove function Klass::cast() and calls to it.
Reviewed-by: dholmes, coleenp

duke@435 1 /*
jprovino@4165 2 * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * questions.
duke@435 22 *
duke@435 23 */
duke@435 24
stefank@2314 25 #ifndef SHARE_VM_SERVICES_CLASSLOADINGSERVICE_HPP
stefank@2314 26 #define SHARE_VM_SERVICES_CLASSLOADINGSERVICE_HPP
stefank@2314 27
stefank@2314 28 #include "runtime/handles.hpp"
stefank@2314 29 #include "runtime/perfData.hpp"
stefank@2314 30 #include "utilities/growableArray.hpp"
stefank@2314 31
coleenp@4037 32 class InstanceKlass;
duke@435 33
duke@435 34 // VM monitoring and management support for the Class Loading subsystem
duke@435 35 class ClassLoadingService : public AllStatic {
duke@435 36 private:
duke@435 37 // Counters for classes loaded from class files
duke@435 38 static PerfCounter* _classes_loaded_count;
duke@435 39 static PerfCounter* _classes_unloaded_count;
duke@435 40 static PerfCounter* _classbytes_loaded;
duke@435 41 static PerfCounter* _classbytes_unloaded;
duke@435 42
duke@435 43 // Counters for classes loaded from shared archive
duke@435 44 static PerfCounter* _shared_classes_loaded_count;
duke@435 45 static PerfCounter* _shared_classes_unloaded_count;
duke@435 46 static PerfCounter* _shared_classbytes_loaded;
duke@435 47 static PerfCounter* _shared_classbytes_unloaded;
duke@435 48
duke@435 49 static PerfVariable* _class_methods_size;
duke@435 50
coleenp@4037 51 static size_t compute_class_size(InstanceKlass* k);
duke@435 52
duke@435 53 public:
duke@435 54 static void init();
duke@435 55
duke@435 56 static bool get_verbose() { return TraceClassLoading; }
duke@435 57 static bool set_verbose(bool verbose);
jprovino@4165 58 static void reset_trace_class_unloading() NOT_MANAGEMENT_RETURN;
duke@435 59
duke@435 60 static jlong loaded_class_count() {
duke@435 61 return _classes_loaded_count->get_value() + _shared_classes_loaded_count->get_value();
duke@435 62 }
duke@435 63 static jlong unloaded_class_count() {
duke@435 64 return _classes_unloaded_count->get_value() + _shared_classes_unloaded_count->get_value();
duke@435 65 }
duke@435 66 static jlong loaded_class_bytes() {
duke@435 67 if (UsePerfData) {
duke@435 68 return _classbytes_loaded->get_value() + _shared_classbytes_loaded->get_value();
duke@435 69 } else {
duke@435 70 return -1;
duke@435 71 }
duke@435 72 }
duke@435 73 static jlong unloaded_class_bytes() {
duke@435 74 if (UsePerfData) {
duke@435 75 return _classbytes_unloaded->get_value() + _shared_classbytes_unloaded->get_value();
duke@435 76 } else {
duke@435 77 return -1;
duke@435 78 }
duke@435 79 }
duke@435 80
duke@435 81 static jlong loaded_shared_class_count() {
duke@435 82 return _shared_classes_loaded_count->get_value();
duke@435 83 }
duke@435 84 static jlong unloaded_shared_class_count() {
duke@435 85 return _shared_classes_unloaded_count->get_value();
duke@435 86 }
duke@435 87 static jlong loaded_shared_class_bytes() {
duke@435 88 if (UsePerfData) {
duke@435 89 return _shared_classbytes_loaded->get_value();
duke@435 90 } else {
duke@435 91 return -1;
duke@435 92 }
duke@435 93 }
duke@435 94 static jlong unloaded_shared_class_bytes() {
duke@435 95 if (UsePerfData) {
duke@435 96 return _shared_classbytes_unloaded->get_value();
duke@435 97 } else {
duke@435 98 return -1;
duke@435 99 }
duke@435 100 }
duke@435 101 static jlong class_method_data_size() {
duke@435 102 return (UsePerfData ? _class_methods_size->get_value() : -1);
duke@435 103 }
duke@435 104
jprovino@4165 105 static void notify_class_loaded(InstanceKlass* k, bool shared_class)
jprovino@4165 106 NOT_MANAGEMENT_RETURN;
duke@435 107 // All unloaded classes are non-shared
jprovino@4165 108 static void notify_class_unloaded(InstanceKlass* k) NOT_MANAGEMENT_RETURN;
duke@435 109 static void add_class_method_size(int size) {
jprovino@4165 110 #if INCLUDE_MANAGEMENT
duke@435 111 if (UsePerfData) {
duke@435 112 _class_methods_size->inc(size);
duke@435 113 }
jprovino@4165 114 #endif // INCLUDE_MANAGEMENT
duke@435 115 }
duke@435 116 };
duke@435 117
duke@435 118 // FIXME: make this piece of code to be shared by M&M and JVMTI
duke@435 119 class LoadedClassesEnumerator : public StackObj {
duke@435 120 private:
duke@435 121 static GrowableArray<KlassHandle>* _loaded_classes;
duke@435 122 // _current_thread is for creating a KlassHandle with a faster version constructor
duke@435 123 static Thread* _current_thread;
duke@435 124
duke@435 125 GrowableArray<KlassHandle>* _klass_handle_array;
duke@435 126
duke@435 127 public:
duke@435 128 LoadedClassesEnumerator(Thread* cur_thread);
duke@435 129
duke@435 130 int num_loaded_classes() { return _klass_handle_array->length(); }
duke@435 131 KlassHandle get_klass(int index) { return _klass_handle_array->at(index); }
duke@435 132
coleenp@4037 133 static void add_loaded_class(Klass* k) {
duke@435 134 // FIXME: For now - don't include array klasses
duke@435 135 // The spec is unclear at this point to count array klasses or not
duke@435 136 // and also indirect creation of array of super class and secondaries
duke@435 137 //
hseigel@4278 138 // for (Klass* l = k; l != NULL; l = l->array_klass_or_null()) {
duke@435 139 // KlassHandle h(_current_thread, l);
duke@435 140 // _loaded_classes->append(h);
duke@435 141 // }
duke@435 142 KlassHandle h(_current_thread, k);
duke@435 143 _loaded_classes->append(h);
duke@435 144 }
duke@435 145 };
stefank@2314 146
stefank@2314 147 #endif // SHARE_VM_SERVICES_CLASSLOADINGSERVICE_HPP

mercurial