Path: blob/jdk8u272-b10-aarch32-20201026/hotspot/src/share/vm/classfile/classLoaderStats.hpp
48773 views
/*1* Copyright (c) 2014, 2017, 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_VM_CLASSFILE_CLASSLOADERSTATS_HPP25#define SHARE_VM_CLASSFILE_CLASSLOADERSTATS_HPP262728#include "classfile/classLoaderData.hpp"29#include "oops/klass.hpp"30#include "oops/oopsHierarchy.hpp"31#include "runtime/vm_operations.hpp"32#include "services/diagnosticCommand.hpp"33#include "utilities/resourceHash.hpp"343536class ClassLoaderStatsDCmd : public DCmd {37public:38ClassLoaderStatsDCmd(outputStream* output, bool heap) :39DCmd(output, heap) {40}4142static const char* name() {43return "VM.classloader_stats";44}4546static const char* description() {47return "Print statistics about all ClassLoaders.";48}4950static const char* impact() {51return "Low";52}5354virtual void execute(DCmdSource source, TRAPS);5556static int num_arguments() {57return 0;58}5960static const JavaPermission permission() {61JavaPermission p = {"java.lang.management.ManagementPermission",62"monitor", NULL};63return p;64}65};666768class ClassLoaderStats : public ResourceObj {69public:70ClassLoaderData* _cld;71oop _class_loader;72oop _parent;7374size_t _chunk_sz;75size_t _block_sz;76uintx _classes_count;7778size_t _anon_chunk_sz;79size_t _anon_block_sz;80uintx _anon_classes_count;8182ClassLoaderStats() :83_cld(0),84_class_loader(0),85_parent(0),86_chunk_sz(0),87_block_sz(0),88_classes_count(0),89_anon_block_sz(0),90_anon_chunk_sz(0),91_anon_classes_count(0) {92}93};949596class ClassLoaderStatsClosure : public CLDClosure {97protected:98static bool oop_equals(oop const& s1, oop const& s2) {99return s1 == s2;100}101102static unsigned oop_hash(oop const& s1) {103// Robert Jenkins 1996 & Thomas Wang 1997104// http://web.archive.org/web/20071223173210/http://www.concentric.net/~Ttwang/tech/inthash.htm105uintptr_t tmp = cast_from_oop<uintptr_t>(s1);106unsigned hash = (unsigned)tmp;107hash = ~hash + (hash << 15);108hash = hash ^ (hash >> 12);109hash = hash + (hash << 2);110hash = hash ^ (hash >> 4);111hash = hash * 2057;112hash = hash ^ (hash >> 16);113return hash;114}115116typedef ResourceHashtable<oop, ClassLoaderStats*,117ClassLoaderStatsClosure::oop_hash, ClassLoaderStatsClosure::oop_equals> StatsTable;118119outputStream* _out;120StatsTable* _stats;121uintx _total_loaders;122uintx _total_classes;123size_t _total_chunk_sz;124size_t _total_block_sz;125126public:127ClassLoaderStatsClosure(outputStream* out) :128_out(out),129_total_loaders(0),130_total_block_sz(0),131_total_chunk_sz(0),132_total_classes(0),133_stats(new StatsTable()) {134}135136virtual void do_cld(ClassLoaderData* cld);137virtual bool do_entry(oop const& key, ClassLoaderStats* const& cls);138void print();139140private:141void addEmptyParents(oop cl);142};143144145class ClassLoaderStatsVMOperation : public VM_Operation {146outputStream* _out;147148public:149ClassLoaderStatsVMOperation(outputStream* out) :150_out(out) {151}152153VMOp_Type type() const {154return VMOp_ClassLoaderStatsOperation;155}156157void doit();158};159160#endif // SHARE_VM_CLASSFILE_CLASSLOADERSTATS_HPP161162163