< prev index next >

src/hotspot/share/memory/metaspace/printCLDMetaspaceInfoClosure.cpp

Print this page
rev 60538 : imported patch jep387-misc.patch
   1 /*
   2  * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.

   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */

  24 #include "precompiled.hpp"
  25 #include "classfile/classLoaderData.inline.hpp"
  26 #include "classfile/javaClasses.hpp"

  27 #include "memory/metaspace/printCLDMetaspaceInfoClosure.hpp"
  28 #include "memory/metaspace/printMetaspaceInfoKlassClosure.hpp"
  29 #include "memory/metaspaceShared.hpp"
  30 #include "memory/resourceArea.hpp"
  31 #include "runtime/safepoint.hpp"
  32 #include "utilities/globalDefinitions.hpp"
  33 #include "utilities/ostream.hpp"
  34 
  35 
  36 namespace metaspace {
  37 
  38 PrintCLDMetaspaceInfoClosure::PrintCLDMetaspaceInfoClosure(outputStream* out, size_t scale, bool do_print,
  39     bool do_print_classes, bool break_down_by_chunktype)
  40 : _out(out), _scale(scale), _do_print(do_print), _do_print_classes(do_print_classes)
  41 , _break_down_by_chunktype(break_down_by_chunktype)
  42 , _num_loaders(0), _num_loaders_without_metaspace(0), _num_loaders_unloading(0)
  43 ,  _num_classes(0), _num_classes_shared(0)
  44 {
  45   memset(_num_loaders_by_spacetype, 0, sizeof(_num_loaders_by_spacetype));
  46   memset(_num_classes_by_spacetype, 0, sizeof(_num_classes_by_spacetype));
  47   memset(_num_classes_shared_by_spacetype, 0, sizeof(_num_classes_shared_by_spacetype));
  48 }
  49 


  63   }
  64 
  65 }; // end: PrintKlassInfoClosure
  66 
  67 void PrintCLDMetaspaceInfoClosure::do_cld(ClassLoaderData* cld) {
  68 
  69   assert(SafepointSynchronize::is_at_safepoint(), "Must be at a safepoint");
  70 
  71   if (cld->is_unloading()) {
  72     _num_loaders_unloading ++;
  73     return;
  74   }
  75 
  76   ClassLoaderMetaspace* msp = cld->metaspace_or_null();
  77   if (msp == NULL) {
  78     _num_loaders_without_metaspace ++;
  79     return;
  80   }
  81 
  82   // Collect statistics for this class loader metaspace
  83   ClassLoaderMetaspaceStatistics this_cld_stat;
  84   msp->add_to_statistics(&this_cld_stat);
  85 
  86   // And add it to the running totals
  87   _stats_total.add(this_cld_stat);
  88   _num_loaders ++;
  89   _stats_by_spacetype[msp->space_type()].add(this_cld_stat);
  90   _num_loaders_by_spacetype[msp->space_type()] ++;
  91 
  92   // Count classes loaded by this CLD.
  93   CountKlassClosure ckc;
  94   cld->classes_do(&ckc);
  95   // accumulate.
  96   _num_classes += ckc._num_classes;
  97   _num_classes_by_spacetype[msp->space_type()] += ckc._num_classes;
  98   _num_classes_shared += ckc._num_classes_shared;
  99   _num_classes_shared_by_spacetype[msp->space_type()] += ckc._num_classes_shared;
 100 
 101   // Optionally, print
 102   if (_do_print) {
 103 


   1 /*
   2  * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
   3  * Copyright (c) 2018, 2020 SAP SE. All rights reserved.
   4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   5  *
   6  * This code is free software; you can redistribute it and/or modify it
   7  * under the terms of the GNU General Public License version 2 only, as
   8  * published by the Free Software Foundation.
   9  *
  10  * This code is distributed in the hope that it will be useful, but WITHOUT
  11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  13  * version 2 for more details (a copy is included in the LICENSE file that
  14  * accompanied this code).
  15  *
  16  * You should have received a copy of the GNU General Public License version
  17  * 2 along with this work; if not, write to the Free Software Foundation,
  18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  19  *
  20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  21  * or visit www.oracle.com if you need additional information or have any
  22  * questions.
  23  *
  24  */
  25 
  26 #include "precompiled.hpp"
  27 #include "classfile/classLoaderData.inline.hpp"
  28 #include "classfile/javaClasses.hpp"
  29 #include "memory/metaspace.hpp"
  30 #include "memory/metaspace/printCLDMetaspaceInfoClosure.hpp"
  31 #include "memory/metaspace/printMetaspaceInfoKlassClosure.hpp"
  32 #include "memory/metaspace/metaspaceCommon.hpp"
  33 #include "memory/resourceArea.hpp"
  34 #include "runtime/safepoint.hpp"
  35 #include "utilities/globalDefinitions.hpp"
  36 #include "utilities/ostream.hpp"
  37 
  38 
  39 namespace metaspace {
  40 
  41 PrintCLDMetaspaceInfoClosure::PrintCLDMetaspaceInfoClosure(outputStream* out, size_t scale, bool do_print,
  42     bool do_print_classes, bool break_down_by_chunktype)
  43 : _out(out), _scale(scale), _do_print(do_print), _do_print_classes(do_print_classes)
  44 , _break_down_by_chunktype(break_down_by_chunktype)
  45 , _num_loaders(0), _num_loaders_without_metaspace(0), _num_loaders_unloading(0)
  46 ,  _num_classes(0), _num_classes_shared(0)
  47 {
  48   memset(_num_loaders_by_spacetype, 0, sizeof(_num_loaders_by_spacetype));
  49   memset(_num_classes_by_spacetype, 0, sizeof(_num_classes_by_spacetype));
  50   memset(_num_classes_shared_by_spacetype, 0, sizeof(_num_classes_shared_by_spacetype));
  51 }
  52 


  66   }
  67 
  68 }; // end: PrintKlassInfoClosure
  69 
  70 void PrintCLDMetaspaceInfoClosure::do_cld(ClassLoaderData* cld) {
  71 
  72   assert(SafepointSynchronize::is_at_safepoint(), "Must be at a safepoint");
  73 
  74   if (cld->is_unloading()) {
  75     _num_loaders_unloading ++;
  76     return;
  77   }
  78 
  79   ClassLoaderMetaspace* msp = cld->metaspace_or_null();
  80   if (msp == NULL) {
  81     _num_loaders_without_metaspace ++;
  82     return;
  83   }
  84 
  85   // Collect statistics for this class loader metaspace
  86   clms_stats_t this_cld_stat;
  87   msp->add_to_statistics(&this_cld_stat);
  88 
  89   // And add it to the running totals
  90   _stats_total.add(this_cld_stat);
  91   _num_loaders ++;
  92   _stats_by_spacetype[msp->space_type()].add(this_cld_stat);
  93   _num_loaders_by_spacetype[msp->space_type()] ++;
  94 
  95   // Count classes loaded by this CLD.
  96   CountKlassClosure ckc;
  97   cld->classes_do(&ckc);
  98   // accumulate.
  99   _num_classes += ckc._num_classes;
 100   _num_classes_by_spacetype[msp->space_type()] += ckc._num_classes;
 101   _num_classes_shared += ckc._num_classes_shared;
 102   _num_classes_shared_by_spacetype[msp->space_type()] += ckc._num_classes_shared;
 103 
 104   // Optionally, print
 105   if (_do_print) {
 106 


< prev index next >