src/share/vm/services/classLoadingService.hpp

Tue, 11 May 2010 14:35:43 -0700

author
prr
date
Tue, 11 May 2010 14:35:43 -0700
changeset 1840
fb57d4cf76c2
parent 435
a61af66fc99e
child 1907
c18cbe5936b8
permissions
-rw-r--r--

6931180: Migration to recent versions of MS Platform SDK
6951582: Build problems on win64
Summary: Changes to enable building JDK7 with Microsoft Visual Studio 2010
Reviewed-by: ohair, art, ccheung, dcubed

duke@435 1 /*
duke@435 2 * Copyright 2003-2005 Sun Microsystems, Inc. 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 *
duke@435 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
duke@435 20 * CA 95054 USA or visit www.sun.com if you need additional information or
duke@435 21 * have any questions.
duke@435 22 *
duke@435 23 */
duke@435 24
duke@435 25 class instanceKlass;
duke@435 26
duke@435 27 // VM monitoring and management support for the Class Loading subsystem
duke@435 28 class ClassLoadingService : public AllStatic {
duke@435 29 private:
duke@435 30 // Counters for classes loaded from class files
duke@435 31 static PerfCounter* _classes_loaded_count;
duke@435 32 static PerfCounter* _classes_unloaded_count;
duke@435 33 static PerfCounter* _classbytes_loaded;
duke@435 34 static PerfCounter* _classbytes_unloaded;
duke@435 35
duke@435 36 // Counters for classes loaded from shared archive
duke@435 37 static PerfCounter* _shared_classes_loaded_count;
duke@435 38 static PerfCounter* _shared_classes_unloaded_count;
duke@435 39 static PerfCounter* _shared_classbytes_loaded;
duke@435 40 static PerfCounter* _shared_classbytes_unloaded;
duke@435 41
duke@435 42 static PerfVariable* _class_methods_size;
duke@435 43
duke@435 44 static size_t compute_class_size(instanceKlass* k);
duke@435 45
duke@435 46 public:
duke@435 47 static void init();
duke@435 48
duke@435 49 static bool get_verbose() { return TraceClassLoading; }
duke@435 50 static bool set_verbose(bool verbose);
duke@435 51 static void reset_trace_class_unloading();
duke@435 52
duke@435 53 static jlong loaded_class_count() {
duke@435 54 return _classes_loaded_count->get_value() + _shared_classes_loaded_count->get_value();
duke@435 55 }
duke@435 56 static jlong unloaded_class_count() {
duke@435 57 return _classes_unloaded_count->get_value() + _shared_classes_unloaded_count->get_value();
duke@435 58 }
duke@435 59 static jlong loaded_class_bytes() {
duke@435 60 if (UsePerfData) {
duke@435 61 return _classbytes_loaded->get_value() + _shared_classbytes_loaded->get_value();
duke@435 62 } else {
duke@435 63 return -1;
duke@435 64 }
duke@435 65 }
duke@435 66 static jlong unloaded_class_bytes() {
duke@435 67 if (UsePerfData) {
duke@435 68 return _classbytes_unloaded->get_value() + _shared_classbytes_unloaded->get_value();
duke@435 69 } else {
duke@435 70 return -1;
duke@435 71 }
duke@435 72 }
duke@435 73
duke@435 74 static jlong loaded_shared_class_count() {
duke@435 75 return _shared_classes_loaded_count->get_value();
duke@435 76 }
duke@435 77 static jlong unloaded_shared_class_count() {
duke@435 78 return _shared_classes_unloaded_count->get_value();
duke@435 79 }
duke@435 80 static jlong loaded_shared_class_bytes() {
duke@435 81 if (UsePerfData) {
duke@435 82 return _shared_classbytes_loaded->get_value();
duke@435 83 } else {
duke@435 84 return -1;
duke@435 85 }
duke@435 86 }
duke@435 87 static jlong unloaded_shared_class_bytes() {
duke@435 88 if (UsePerfData) {
duke@435 89 return _shared_classbytes_unloaded->get_value();
duke@435 90 } else {
duke@435 91 return -1;
duke@435 92 }
duke@435 93 }
duke@435 94 static jlong class_method_data_size() {
duke@435 95 return (UsePerfData ? _class_methods_size->get_value() : -1);
duke@435 96 }
duke@435 97
duke@435 98 static void notify_class_loaded(instanceKlass* k, bool shared_class);
duke@435 99 // All unloaded classes are non-shared
duke@435 100 static void notify_class_unloaded(instanceKlass* k);
duke@435 101 static void add_class_method_size(int size) {
duke@435 102 if (UsePerfData) {
duke@435 103 _class_methods_size->inc(size);
duke@435 104 }
duke@435 105 }
duke@435 106 };
duke@435 107
duke@435 108 // FIXME: make this piece of code to be shared by M&M and JVMTI
duke@435 109 class LoadedClassesEnumerator : public StackObj {
duke@435 110 private:
duke@435 111 static GrowableArray<KlassHandle>* _loaded_classes;
duke@435 112 // _current_thread is for creating a KlassHandle with a faster version constructor
duke@435 113 static Thread* _current_thread;
duke@435 114
duke@435 115 GrowableArray<KlassHandle>* _klass_handle_array;
duke@435 116
duke@435 117 public:
duke@435 118 LoadedClassesEnumerator(Thread* cur_thread);
duke@435 119
duke@435 120 int num_loaded_classes() { return _klass_handle_array->length(); }
duke@435 121 KlassHandle get_klass(int index) { return _klass_handle_array->at(index); }
duke@435 122
duke@435 123 static void add_loaded_class(klassOop k) {
duke@435 124 // FIXME: For now - don't include array klasses
duke@435 125 // The spec is unclear at this point to count array klasses or not
duke@435 126 // and also indirect creation of array of super class and secondaries
duke@435 127 //
duke@435 128 // for (klassOop l = k; l != NULL; l = Klass::cast(l)->array_klass_or_null()) {
duke@435 129 // KlassHandle h(_current_thread, l);
duke@435 130 // _loaded_classes->append(h);
duke@435 131 // }
duke@435 132 KlassHandle h(_current_thread, k);
duke@435 133 _loaded_classes->append(h);
duke@435 134 }
duke@435 135 };

mercurial