src/share/vm/services/classLoadingService.hpp

Wed, 23 Jan 2013 13:02:39 -0500

author
jprovino
date
Wed, 23 Jan 2013 13:02:39 -0500
changeset 4542
db9981fd3124
parent 4278
070d523b96a7
child 6198
55fb97c4c58d
permissions
-rw-r--r--

8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
Summary: Rename INCLUDE_ALTERNATE_GCS to INCLUDE_ALL_GCS and replace SERIALGC with INCLUDE_ALL_GCS.
Reviewed-by: coleenp, stefank

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"
jprovino@4542 31 #include "utilities/macros.hpp"
stefank@2314 32
coleenp@4037 33 class InstanceKlass;
duke@435 34
duke@435 35 // VM monitoring and management support for the Class Loading subsystem
duke@435 36 class ClassLoadingService : public AllStatic {
duke@435 37 private:
duke@435 38 // Counters for classes loaded from class files
duke@435 39 static PerfCounter* _classes_loaded_count;
duke@435 40 static PerfCounter* _classes_unloaded_count;
duke@435 41 static PerfCounter* _classbytes_loaded;
duke@435 42 static PerfCounter* _classbytes_unloaded;
duke@435 43
duke@435 44 // Counters for classes loaded from shared archive
duke@435 45 static PerfCounter* _shared_classes_loaded_count;
duke@435 46 static PerfCounter* _shared_classes_unloaded_count;
duke@435 47 static PerfCounter* _shared_classbytes_loaded;
duke@435 48 static PerfCounter* _shared_classbytes_unloaded;
duke@435 49
duke@435 50 static PerfVariable* _class_methods_size;
duke@435 51
coleenp@4037 52 static size_t compute_class_size(InstanceKlass* k);
duke@435 53
duke@435 54 public:
duke@435 55 static void init();
duke@435 56
duke@435 57 static bool get_verbose() { return TraceClassLoading; }
duke@435 58 static bool set_verbose(bool verbose);
jprovino@4165 59 static void reset_trace_class_unloading() NOT_MANAGEMENT_RETURN;
duke@435 60
duke@435 61 static jlong loaded_class_count() {
duke@435 62 return _classes_loaded_count->get_value() + _shared_classes_loaded_count->get_value();
duke@435 63 }
duke@435 64 static jlong unloaded_class_count() {
duke@435 65 return _classes_unloaded_count->get_value() + _shared_classes_unloaded_count->get_value();
duke@435 66 }
duke@435 67 static jlong loaded_class_bytes() {
duke@435 68 if (UsePerfData) {
duke@435 69 return _classbytes_loaded->get_value() + _shared_classbytes_loaded->get_value();
duke@435 70 } else {
duke@435 71 return -1;
duke@435 72 }
duke@435 73 }
duke@435 74 static jlong unloaded_class_bytes() {
duke@435 75 if (UsePerfData) {
duke@435 76 return _classbytes_unloaded->get_value() + _shared_classbytes_unloaded->get_value();
duke@435 77 } else {
duke@435 78 return -1;
duke@435 79 }
duke@435 80 }
duke@435 81
duke@435 82 static jlong loaded_shared_class_count() {
duke@435 83 return _shared_classes_loaded_count->get_value();
duke@435 84 }
duke@435 85 static jlong unloaded_shared_class_count() {
duke@435 86 return _shared_classes_unloaded_count->get_value();
duke@435 87 }
duke@435 88 static jlong loaded_shared_class_bytes() {
duke@435 89 if (UsePerfData) {
duke@435 90 return _shared_classbytes_loaded->get_value();
duke@435 91 } else {
duke@435 92 return -1;
duke@435 93 }
duke@435 94 }
duke@435 95 static jlong unloaded_shared_class_bytes() {
duke@435 96 if (UsePerfData) {
duke@435 97 return _shared_classbytes_unloaded->get_value();
duke@435 98 } else {
duke@435 99 return -1;
duke@435 100 }
duke@435 101 }
duke@435 102 static jlong class_method_data_size() {
duke@435 103 return (UsePerfData ? _class_methods_size->get_value() : -1);
duke@435 104 }
duke@435 105
jprovino@4165 106 static void notify_class_loaded(InstanceKlass* k, bool shared_class)
jprovino@4165 107 NOT_MANAGEMENT_RETURN;
duke@435 108 // All unloaded classes are non-shared
jprovino@4165 109 static void notify_class_unloaded(InstanceKlass* k) NOT_MANAGEMENT_RETURN;
duke@435 110 static void add_class_method_size(int size) {
jprovino@4165 111 #if INCLUDE_MANAGEMENT
duke@435 112 if (UsePerfData) {
duke@435 113 _class_methods_size->inc(size);
duke@435 114 }
jprovino@4165 115 #endif // INCLUDE_MANAGEMENT
duke@435 116 }
duke@435 117 };
duke@435 118
duke@435 119 // FIXME: make this piece of code to be shared by M&M and JVMTI
duke@435 120 class LoadedClassesEnumerator : public StackObj {
duke@435 121 private:
duke@435 122 static GrowableArray<KlassHandle>* _loaded_classes;
duke@435 123 // _current_thread is for creating a KlassHandle with a faster version constructor
duke@435 124 static Thread* _current_thread;
duke@435 125
duke@435 126 GrowableArray<KlassHandle>* _klass_handle_array;
duke@435 127
duke@435 128 public:
duke@435 129 LoadedClassesEnumerator(Thread* cur_thread);
duke@435 130
duke@435 131 int num_loaded_classes() { return _klass_handle_array->length(); }
duke@435 132 KlassHandle get_klass(int index) { return _klass_handle_array->at(index); }
duke@435 133
coleenp@4037 134 static void add_loaded_class(Klass* k) {
duke@435 135 // FIXME: For now - don't include array klasses
duke@435 136 // The spec is unclear at this point to count array klasses or not
duke@435 137 // and also indirect creation of array of super class and secondaries
duke@435 138 //
hseigel@4278 139 // for (Klass* l = k; l != NULL; l = l->array_klass_or_null()) {
duke@435 140 // KlassHandle h(_current_thread, l);
duke@435 141 // _loaded_classes->append(h);
duke@435 142 // }
duke@435 143 KlassHandle h(_current_thread, k);
duke@435 144 _loaded_classes->append(h);
duke@435 145 }
duke@435 146 };
stefank@2314 147
stefank@2314 148 #endif // SHARE_VM_SERVICES_CLASSLOADINGSERVICE_HPP

mercurial