src/hotspot/share/classfile/classLoaderStats.cpp
author lfoltan
Mon, 21 Oct 2019 13:13:16 -0400
changeset 58722 cba8afa5cfed
parent 52586 74109912c738
child 58063 bdf136b8ae0e
permissions -rw-r--r--
8231844: Enhance type signature characters in classfile_constants.h and improve the JVM to use type signature characters more consistently Summary: Increase the use of type signature constants instead of hard coded characters within the JVM. Reviewed-by: coleenp, dholmes, fparain Contributed-by: lois.foltan@oracle.com, john.r.rose@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
25051
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
     1
/*
49824
e242740a92b8 8201556: Disallow reading oops in ClassLoaderData if unloading
coleenp
parents: 49401
diff changeset
     2
 * Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
25051
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
     4
 *
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
     7
 * published by the Free Software Foundation.
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
     8
 *
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
    13
 * accompanied this code).
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
    14
 *
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
    18
 *
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
    21
 * questions.
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
    22
 *
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
    23
 */
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
    24
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
    25
#include "precompiled.hpp"
49824
e242740a92b8 8201556: Disallow reading oops in ClassLoaderData if unloading
coleenp
parents: 49401
diff changeset
    26
#include "classfile/classLoaderData.inline.hpp"
51959
db0c3952de52 8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents: 51698
diff changeset
    27
#include "classfile/classLoaderDataGraph.hpp"
25051
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
    28
#include "classfile/classLoaderStats.hpp"
29081
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents: 25051
diff changeset
    29
#include "oops/oop.inline.hpp"
25051
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
    30
#include "utilities/globalDefinitions.hpp"
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
    31
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
    32
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
    33
class ClassStatsClosure : public KlassClosure {
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
    34
public:
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
    35
  int _num_classes;
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
    36
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
    37
  ClassStatsClosure() :
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
    38
    _num_classes(0) {
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
    39
  }
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
    40
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
    41
  virtual void do_klass(Klass* k) {
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
    42
    _num_classes++;
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
    43
  }
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
    44
};
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
    45
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
    46
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
    47
void ClassLoaderStatsClosure::do_cld(ClassLoaderData* cld) {
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
    48
  oop cl = cld->class_loader();
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
    49
  ClassLoaderStats* cls;
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
    50
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
    51
  // The hashtable key is the ClassLoader oop since we want to account
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
    52
  // for "real" classes and anonymous classes together
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
    53
  ClassLoaderStats** cls_ptr = _stats->get(cl);
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
    54
  if (cls_ptr == NULL) {
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
    55
    cls = new ClassLoaderStats();
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
    56
    _stats->put(cl, cls);
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
    57
    _total_loaders++;
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
    58
  } else {
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
    59
    cls = *cls_ptr;
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
    60
  }
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
    61
51444
3e5d28e6de32 8209301: JVM rename is_anonymous, host_klass to unsafe specific terminology ahead of Unsafe.defineAnonymousClass deprecation
lfoltan
parents: 49824
diff changeset
    62
  if (!cld->is_unsafe_anonymous()) {
25051
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
    63
    cls->_cld = cld;
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
    64
  }
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
    65
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
    66
  cls->_class_loader = cl;
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
    67
  if (cl != NULL) {
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
    68
    cls->_parent = java_lang_ClassLoader::parent(cl);
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
    69
    addEmptyParents(cls->_parent);
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
    70
  }
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
    71
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
    72
  ClassStatsClosure csc;
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
    73
  cld->classes_do(&csc);
51444
3e5d28e6de32 8209301: JVM rename is_anonymous, host_klass to unsafe specific terminology ahead of Unsafe.defineAnonymousClass deprecation
lfoltan
parents: 49824
diff changeset
    74
  if(cld->is_unsafe_anonymous()) {
25051
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
    75
    cls->_anon_classes_count += csc._num_classes;
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
    76
  } else {
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
    77
    cls->_classes_count = csc._num_classes;
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
    78
  }
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
    79
  _total_classes += csc._num_classes;
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
    80
49401
0c71baee49a7 8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents: 47216
diff changeset
    81
  ClassLoaderMetaspace* ms = cld->metaspace_or_null();
25051
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
    82
  if (ms != NULL) {
51444
3e5d28e6de32 8209301: JVM rename is_anonymous, host_klass to unsafe specific terminology ahead of Unsafe.defineAnonymousClass deprecation
lfoltan
parents: 49824
diff changeset
    83
    if(cld->is_unsafe_anonymous()) {
25051
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
    84
      cls->_anon_chunk_sz += ms->allocated_chunks_bytes();
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
    85
      cls->_anon_block_sz += ms->allocated_blocks_bytes();
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
    86
    } else {
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
    87
      cls->_chunk_sz = ms->allocated_chunks_bytes();
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
    88
      cls->_block_sz = ms->allocated_blocks_bytes();
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
    89
    }
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
    90
    _total_chunk_sz += ms->allocated_chunks_bytes();
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
    91
    _total_block_sz += ms->allocated_blocks_bytes();
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
    92
  }
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
    93
}
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
    94
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
    95
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
    96
// Handles the difference in pointer width on 32 and 64 bit platforms
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
    97
#ifdef _LP64
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
    98
  #define SPACE "%8s"
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
    99
#else
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
   100
  #define SPACE "%s"
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
   101
#endif
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
   102
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
   103
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
   104
bool ClassLoaderStatsClosure::do_entry(oop const& key, ClassLoaderStats* const& cls) {
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
   105
  Klass* class_loader_klass = (cls->_class_loader == NULL ? NULL : cls->_class_loader->klass());
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
   106
  Klass* parent_klass = (cls->_parent == NULL ? NULL : cls->_parent->klass());
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
   107
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
   108
  _out->print(INTPTR_FORMAT "  " INTPTR_FORMAT "  " INTPTR_FORMAT "  " UINTX_FORMAT_W(6) "  " SIZE_FORMAT_W(8) "  " SIZE_FORMAT_W(8) "  ",
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
   109
      p2i(class_loader_klass), p2i(parent_klass), p2i(cls->_cld),
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
   110
      cls->_classes_count,
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
   111
      cls->_chunk_sz, cls->_block_sz);
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
   112
  if (class_loader_klass != NULL) {
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
   113
    _out->print("%s", class_loader_klass->external_name());
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
   114
  } else {
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
   115
    _out->print("<boot class loader>");
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
   116
  }
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
   117
  _out->cr();
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
   118
  if (cls->_anon_classes_count > 0) {
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
   119
    _out->print_cr(SPACE SPACE SPACE "                                    " UINTX_FORMAT_W(6) "  " SIZE_FORMAT_W(8) "  " SIZE_FORMAT_W(8) "   + unsafe anonymous classes",
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
   120
        "", "", "",
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
   121
        cls->_anon_classes_count,
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
   122
        cls->_anon_chunk_sz, cls->_anon_block_sz);
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
   123
  }
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
   124
  return true;
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
   125
}
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
   126
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
   127
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
   128
void ClassLoaderStatsClosure::print() {
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
   129
  _out->print_cr("ClassLoader" SPACE " Parent" SPACE "      CLD*" SPACE "       Classes   ChunkSz   BlockSz  Type", "", "", "");
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
   130
  _stats->iterate(this);
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
   131
  _out->print("Total = " UINTX_FORMAT_W(-6), _total_loaders);
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
   132
  _out->print(SPACE SPACE SPACE "                      ", "", "", "");
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
   133
  _out->print_cr(UINTX_FORMAT_W(6) "  " SIZE_FORMAT_W(8) "  " SIZE_FORMAT_W(8) "  ",
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
   134
      _total_classes,
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
   135
      _total_chunk_sz,
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
   136
      _total_block_sz);
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
   137
  _out->print_cr("ChunkSz: Total size of all allocated metaspace chunks");
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
   138
  _out->print_cr("BlockSz: Total size of all allocated metaspace blocks (each chunk has several blocks)");
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
   139
}
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
   140
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
   141
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
   142
void ClassLoaderStatsClosure::addEmptyParents(oop cl) {
51698
74dde8b66b7f 8210422: runtime/modules/ModuleStress/ExportModuleStressTest.java - assertion failed: address not aligned: 0x00000008baadbabe
coleenp
parents: 51444
diff changeset
   143
  while (cl != NULL && java_lang_ClassLoader::loader_data_acquire(cl) == NULL) {
25051
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
   144
    // This classloader has not loaded any classes
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
   145
    ClassLoaderStats** cls_ptr = _stats->get(cl);
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
   146
    if (cls_ptr == NULL) {
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
   147
      // It does not exist in our table - add it
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
   148
      ClassLoaderStats* cls = new ClassLoaderStats();
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
   149
      cls->_class_loader = cl;
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
   150
      cls->_parent = java_lang_ClassLoader::parent(cl);
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
   151
      _stats->put(cl, cls);
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
   152
      _total_loaders++;
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
   153
    }
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
   154
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
   155
    cl = java_lang_ClassLoader::parent(cl);
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
   156
  }
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
   157
}
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
   158
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
   159
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
   160
void ClassLoaderStatsVMOperation::doit() {
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
   161
  ClassLoaderStatsClosure clsc (_out);
52586
74109912c738 8213751: ClassLoaderDataGraph::cld_do() should sometimes require CLDG_lock
coleenp
parents: 51959
diff changeset
   162
  ClassLoaderDataGraph::loaded_cld_do(&clsc);
25051
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
   163
  clsc.print();
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
   164
}
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
   165
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
   166
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
   167
void ClassLoaderStatsDCmd::execute(DCmdSource source, TRAPS) {
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
   168
  ClassLoaderStatsVMOperation op(output());
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
   169
  VMThread::execute(&op);
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents:
diff changeset
   170
}