Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/classfile/classLoaderStats.hpp
32285 views
/*1* Copyright (c) 2014, 2018, 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/oop.hpp"31#include "oops/oopsHierarchy.hpp"32#include "runtime/vm_operations.hpp"33#include "services/diagnosticCommand.hpp"34#include "utilities/resourceHash.hpp"353637class ClassLoaderStatsDCmd : public DCmd {38public:39ClassLoaderStatsDCmd(outputStream* output, bool heap) :40DCmd(output, heap) {41}4243static const char* name() {44return "VM.classloader_stats";45}4647static const char* description() {48return "Print statistics about all ClassLoaders.";49}5051static const char* impact() {52return "Low";53}5455virtual void execute(DCmdSource source, TRAPS);5657static int num_arguments() {58return 0;59}6061static const JavaPermission permission() {62JavaPermission p = {"java.lang.management.ManagementPermission",63"monitor", NULL};64return p;65}66};676869class ClassLoaderStats : public ResourceObj {70public:71ClassLoaderData* _cld;72oop _class_loader;73oop _parent;7475size_t _chunk_sz;76size_t _block_sz;77uintx _classes_count;7879size_t _anon_chunk_sz;80size_t _anon_block_sz;81uintx _anon_classes_count;8283ClassLoaderStats() :84_cld(0),85_class_loader(0),86_parent(0),87_chunk_sz(0),88_block_sz(0),89_classes_count(0),90_anon_block_sz(0),91_anon_chunk_sz(0),92_anon_classes_count(0) {93}94};959697class ClassLoaderStatsClosure : public CLDClosure {98protected:99static bool oop_equals(oop const& s1, oop const& s2) {100return s1 == s2;101}102103static unsigned oop_hash(oop const& s1) {104// Robert Jenkins 1996 & Thomas Wang 1997105// http://web.archive.org/web/20071223173210/http://www.concentric.net/~Ttwang/tech/inthash.htm106uintptr_t tmp = cast_from_oop<uintptr_t>(s1);107unsigned hash = (unsigned)tmp;108hash = ~hash + (hash << 15);109hash = hash ^ (hash >> 12);110hash = hash + (hash << 2);111hash = hash ^ (hash >> 4);112hash = hash * 2057;113hash = hash ^ (hash >> 16);114return hash;115}116117typedef ResourceHashtable<oop, ClassLoaderStats*,118ClassLoaderStatsClosure::oop_hash, ClassLoaderStatsClosure::oop_equals> StatsTable;119120outputStream* _out;121StatsTable* _stats;122uintx _total_loaders;123uintx _total_classes;124size_t _total_chunk_sz;125size_t _total_block_sz;126127public:128ClassLoaderStatsClosure(outputStream* out) :129_out(out),130_total_loaders(0),131_total_block_sz(0),132_total_chunk_sz(0),133_total_classes(0),134_stats(new StatsTable()) {135}136137virtual void do_cld(ClassLoaderData* cld);138virtual bool do_entry(oop const& key, ClassLoaderStats* const& cls);139void print();140141private:142void addEmptyParents(oop cl);143};144145146class ClassLoaderStatsVMOperation : public VM_Operation {147outputStream* _out;148149public:150ClassLoaderStatsVMOperation(outputStream* out) :151_out(out) {152}153154VMOp_Type type() const {155return VMOp_ClassLoaderStatsOperation;156}157158void doit();159};160161#endif // SHARE_VM_CLASSFILE_CLASSLOADERSTATS_HPP162163164