Path: blob/master/src/hotspot/share/services/classLoadingService.hpp
41144 views
/*1* Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#ifndef SHARE_SERVICES_CLASSLOADINGSERVICE_HPP25#define SHARE_SERVICES_CLASSLOADINGSERVICE_HPP2627#include "logging/log.hpp"28#include "runtime/handles.hpp"29#include "runtime/perfData.hpp"30#include "utilities/growableArray.hpp"31#include "utilities/macros.hpp"3233class InstanceKlass;3435// VM monitoring and management support for the Class Loading subsystem36class ClassLoadingService : public AllStatic {37private:38// Counters for classes loaded from class files39static PerfCounter* _classes_loaded_count;40static PerfCounter* _classes_unloaded_count;41static PerfCounter* _classbytes_loaded;42static PerfCounter* _classbytes_unloaded;4344// Counters for classes loaded from shared archive45static PerfCounter* _shared_classes_loaded_count;46static PerfCounter* _shared_classes_unloaded_count;47static PerfCounter* _shared_classbytes_loaded;48static PerfCounter* _shared_classbytes_unloaded;4950static PerfVariable* _class_methods_size;5152static size_t compute_class_size(InstanceKlass* k);5354public:55static void init();5657static bool get_verbose() { return log_is_enabled(Info, class, load); }58static bool set_verbose(bool verbose);59static void reset_trace_class_unloading() NOT_MANAGEMENT_RETURN;6061static jlong loaded_class_count() {62return _classes_loaded_count->get_value() + _shared_classes_loaded_count->get_value();63}64static jlong unloaded_class_count() {65return _classes_unloaded_count->get_value() + _shared_classes_unloaded_count->get_value();66}67static jlong loaded_class_bytes() {68if (UsePerfData) {69return _classbytes_loaded->get_value() + _shared_classbytes_loaded->get_value();70} else {71return -1;72}73}74static jlong unloaded_class_bytes() {75if (UsePerfData) {76return _classbytes_unloaded->get_value() + _shared_classbytes_unloaded->get_value();77} else {78return -1;79}80}8182static jlong loaded_shared_class_count() {83return _shared_classes_loaded_count->get_value();84}85static jlong unloaded_shared_class_count() {86return _shared_classes_unloaded_count->get_value();87}88static jlong loaded_shared_class_bytes() {89if (UsePerfData) {90return _shared_classbytes_loaded->get_value();91} else {92return -1;93}94}95static jlong unloaded_shared_class_bytes() {96if (UsePerfData) {97return _shared_classbytes_unloaded->get_value();98} else {99return -1;100}101}102static jlong class_method_data_size() {103return (UsePerfData ? _class_methods_size->get_value() : -1);104}105106static void notify_class_loaded(InstanceKlass* k, bool shared_class)107NOT_MANAGEMENT_RETURN;108// All unloaded classes are non-shared109static void notify_class_unloaded(InstanceKlass* k) NOT_MANAGEMENT_RETURN;110static void add_class_method_size(int size) {111#if INCLUDE_MANAGEMENT112if (UsePerfData) {113_class_methods_size->inc(size);114}115#endif // INCLUDE_MANAGEMENT116}117};118119#endif // SHARE_SERVICES_CLASSLOADINGSERVICE_HPP120121122