hotspot/src/share/vm/classfile/classLoaderData.hpp
author lfoltan
Tue, 28 Jun 2016 10:11:01 -0400
changeset 39616 f82b1f888578
parent 38937 2bf3c37c4841
child 40358 48774f26918a
permissions -rw-r--r--
8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined Summary: Fixed an issue in class unloading to delay walk until class loader's aliveness is determined of modularity lists to remove dead modules Reviewed-by: coleenp, dholmes, sspitsyn, zgu
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
     1
/*
35498
392b50de06c6 8146401: Clean up oop.hpp: add inline directives and fix header files
goetz
parents: 34666
diff changeset
     2
 * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
     4
 *
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
     7
 * published by the Free Software Foundation.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
     8
 *
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14847
92a59a418262 8004982: JDK8 source with GPL header errors
katleman
parents: 14588
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    13
 * accompanied this code).
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    14
 *
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    18
 *
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    21
 * questions.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    22
 *
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    23
 */
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    24
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    25
#ifndef SHARE_VM_CLASSFILE_CLASSLOADERDATA_HPP
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    26
#define SHARE_VM_CLASSFILE_CLASSLOADERDATA_HPP
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    27
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    28
#include "memory/allocation.hpp"
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    29
#include "memory/memRegion.hpp"
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    30
#include "memory/metaspace.hpp"
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    31
#include "memory/metaspaceCounters.hpp"
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    32
#include "runtime/mutex.hpp"
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    33
#include "utilities/growableArray.hpp"
27673
df559a888b9f 8065361: Fixup headers and definitions for INCLUDE_TRACE
mgronlun
parents: 27461
diff changeset
    34
#include "utilities/macros.hpp"
18025
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17110
diff changeset
    35
#if INCLUDE_TRACE
27673
df559a888b9f 8065361: Fixup headers and definitions for INCLUDE_TRACE
mgronlun
parents: 27461
diff changeset
    36
#include "utilities/ticks.hpp"
18025
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17110
diff changeset
    37
#endif
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17110
diff changeset
    38
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    39
//
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    40
// A class loader represents a linkset. Conceptually, a linkset identifies
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    41
// the complete transitive closure of resolved links that a dynamic linker can
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    42
// produce.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    43
//
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    44
// A ClassLoaderData also encapsulates the allocation space, called a metaspace,
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    45
// used by the dynamic linker to allocate the runtime representation of all
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    46
// the types it defines.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    47
//
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    48
// ClassLoaderData are stored in the runtime representation of classes and the
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    49
// system dictionary, are roots of garbage collection, and provides iterators
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    50
// for root tracing and other GC operations.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    51
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    52
class ClassLoaderData;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    53
class JNIMethodBlock;
31046
d01ad7a0ecb0 8081320: Backout JDK-8059340: ConstantPool::_resolved_references is missing in heap dump
vlivanov
parents: 31038
diff changeset
    54
class JNIHandleBlock;
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    55
class Metadebug;
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 35917
diff changeset
    56
class ModuleEntry;
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 35917
diff changeset
    57
class PackageEntry;
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 35917
diff changeset
    58
class ModuleEntryTable;
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 35917
diff changeset
    59
class PackageEntryTable;
18025
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17110
diff changeset
    60
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    61
// GC root for walking class loader data created
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    62
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    63
class ClassLoaderDataGraph : public AllStatic {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    64
  friend class ClassLoaderData;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    65
  friend class ClassLoaderDataGraphMetaspaceIterator;
25492
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
    66
  friend class ClassLoaderDataGraphKlassIteratorAtomic;
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    67
  friend class VMStructs;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    68
 private:
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    69
  // All CLDs (except the null CLD) can be reached by walking _head->_next->...
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    70
  static ClassLoaderData* _head;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    71
  static ClassLoaderData* _unloading;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    72
  // CMS support.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    73
  static ClassLoaderData* _saved_head;
25371
564ab3b08082 8047812: Ensure ClassLoaderDataGraph::classes_unloading_do only delivers klasses from CLDs with non-reclaimed class loader oops
mgronlun
parents: 25325
diff changeset
    74
  static ClassLoaderData* _saved_unloading;
24457
0e20b36df5c4 8038212: Method::is_valid_method() check has performance regression impact for stackwalking
coleenp
parents: 23526
diff changeset
    75
  static bool _should_purge;
27461
90e9e0f9c0c5 8037842: Failing to allocate MethodCounters and MDO causes a serious performance drop
coleenp
parents: 27247
diff changeset
    76
  // OOM has been seen in metaspace allocation. Used to prevent some
90e9e0f9c0c5 8037842: Failing to allocate MethodCounters and MDO causes a serious performance drop
coleenp
parents: 27247
diff changeset
    77
  // allocations until class unloading
90e9e0f9c0c5 8037842: Failing to allocate MethodCounters and MDO causes a serious performance drop
coleenp
parents: 27247
diff changeset
    78
  static bool _metaspace_oom;
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    79
17107
46fc21b30a1e 8011802: NPG: init_dependencies in class loader data graph can cause invalid CLD
mgerdin
parents: 16684
diff changeset
    80
  static ClassLoaderData* add(Handle class_loader, bool anonymous, TRAPS);
18025
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17110
diff changeset
    81
  static void post_class_unload_events(void);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    82
 public:
14588
8ec26d2d9339 8000662: NPG: nashorn ant clean test262 out-of-memory with Java heap
coleenp
parents: 13759
diff changeset
    83
  static ClassLoaderData* find_or_create(Handle class_loader, TRAPS);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    84
  static void purge();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    85
  static void clear_claimed_marks();
25492
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
    86
  // oops do
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    87
  static void oops_do(OopClosure* f, KlassClosure* klass_closure, bool must_claim);
25492
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
    88
  static void keep_alive_oops_do(OopClosure* blk, KlassClosure* klass_closure, bool must_claim);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    89
  static void always_strong_oops_do(OopClosure* blk, KlassClosure* klass_closure, bool must_claim);
25492
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
    90
  // cld do
25051
8110ec6e7340 8044107: Add Diagnostic Command to list all ClassLoaders
sla
parents: 24457
diff changeset
    91
  static void cld_do(CLDClosure* cl);
25492
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
    92
  static void roots_cld_do(CLDClosure* strong, CLDClosure* weak);
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
    93
  static void keep_alive_cld_do(CLDClosure* cl);
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
    94
  static void always_strong_cld_do(CLDClosure* cl);
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
    95
  // klass do
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    96
  static void classes_do(KlassClosure* klass_closure);
18025
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17110
diff changeset
    97
  static void classes_do(void f(Klass* const));
23526
6851d341ad52 8037970: make PrintMethodData a diagnostic options
roland
parents: 22905
diff changeset
    98
  static void methods_do(void f(Method*));
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 35917
diff changeset
    99
  static void modules_do(void f(ModuleEntry*));
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 35917
diff changeset
   100
  static void modules_unloading_do(void f(ModuleEntry*));
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 35917
diff changeset
   101
  static void packages_do(void f(PackageEntry*));
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 35917
diff changeset
   102
  static void packages_unloading_do(void f(PackageEntry*));
21183
e148e499e5cd 8024423: JVMTI: GetLoadedClasses doesn't enumerate anonymous classes
farvidsson
parents: 18025
diff changeset
   103
  static void loaded_classes_do(KlassClosure* klass_closure);
18025
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17110
diff changeset
   104
  static void classes_unloading_do(void f(Klass* const));
29576
c223b0a9872e 8061205: MetadataOnStackMark only needs to walk code cache during class redefinition
coleenp
parents: 27673
diff changeset
   105
  static bool do_unloading(BoolObjectClosure* is_alive, bool clean_previous_versions);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   106
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   107
  // CMS support.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   108
  static void remember_new_clds(bool remember) { _saved_head = (remember ? _head : NULL); }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   109
  static GrowableArray<ClassLoaderData*>* new_clds();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   110
24457
0e20b36df5c4 8038212: Method::is_valid_method() check has performance regression impact for stackwalking
coleenp
parents: 23526
diff changeset
   111
  static void set_should_purge(bool b) { _should_purge = b; }
0e20b36df5c4 8038212: Method::is_valid_method() check has performance regression impact for stackwalking
coleenp
parents: 23526
diff changeset
   112
  static void purge_if_needed() {
0e20b36df5c4 8038212: Method::is_valid_method() check has performance regression impact for stackwalking
coleenp
parents: 23526
diff changeset
   113
    // Only purge the CLDG for CMS if concurrent sweep is complete.
0e20b36df5c4 8038212: Method::is_valid_method() check has performance regression impact for stackwalking
coleenp
parents: 23526
diff changeset
   114
    if (_should_purge) {
0e20b36df5c4 8038212: Method::is_valid_method() check has performance regression impact for stackwalking
coleenp
parents: 23526
diff changeset
   115
      purge();
0e20b36df5c4 8038212: Method::is_valid_method() check has performance regression impact for stackwalking
coleenp
parents: 23526
diff changeset
   116
      // reset for next time.
0e20b36df5c4 8038212: Method::is_valid_method() check has performance regression impact for stackwalking
coleenp
parents: 23526
diff changeset
   117
      set_should_purge(false);
0e20b36df5c4 8038212: Method::is_valid_method() check has performance regression impact for stackwalking
coleenp
parents: 23526
diff changeset
   118
    }
0e20b36df5c4 8038212: Method::is_valid_method() check has performance regression impact for stackwalking
coleenp
parents: 23526
diff changeset
   119
  }
0e20b36df5c4 8038212: Method::is_valid_method() check has performance regression impact for stackwalking
coleenp
parents: 23526
diff changeset
   120
27461
90e9e0f9c0c5 8037842: Failing to allocate MethodCounters and MDO causes a serious performance drop
coleenp
parents: 27247
diff changeset
   121
  static bool has_metaspace_oom()           { return _metaspace_oom; }
90e9e0f9c0c5 8037842: Failing to allocate MethodCounters and MDO causes a serious performance drop
coleenp
parents: 27247
diff changeset
   122
  static void set_metaspace_oom(bool value) { _metaspace_oom = value; }
90e9e0f9c0c5 8037842: Failing to allocate MethodCounters and MDO causes a serious performance drop
coleenp
parents: 27247
diff changeset
   123
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   124
  static void dump_on(outputStream * const out) PRODUCT_RETURN;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   125
  static void dump() { dump_on(tty); }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   126
  static void verify();
35917
463d67f86eaa 8079408: Reimplement TraceClassLoading, TraceClassUnloading, and TraceClassLoaderData with Unified Logging.
mockner
parents: 35498
diff changeset
   127
  static void log_creation(Handle loader, ClassLoaderData* cld, TRAPS);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   128
25492
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   129
  static bool unload_list_contains(const void* x);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   130
#ifndef PRODUCT
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   131
  static bool contains_loader_data(ClassLoaderData* loader_data);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   132
#endif
18025
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17110
diff changeset
   133
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17110
diff changeset
   134
#if INCLUDE_TRACE
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17110
diff changeset
   135
 private:
21767
41eaa9a17059 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents: 21183
diff changeset
   136
  static Ticks _class_unload_time;
18025
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17110
diff changeset
   137
  static void class_unload_event(Klass* const k);
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17110
diff changeset
   138
#endif
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   139
};
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   140
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   141
// ClassLoaderData class
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   142
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   143
class ClassLoaderData : public CHeapObj<mtClass> {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   144
  friend class VMStructs;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   145
 private:
16684
2af47517ffbd 8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents: 16617
diff changeset
   146
  class Dependencies VALUE_OBJ_CLASS_SPEC {
2af47517ffbd 8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents: 16617
diff changeset
   147
    objArrayOop _list_head;
2af47517ffbd 8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents: 16617
diff changeset
   148
    void locked_add(objArrayHandle last,
2af47517ffbd 8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents: 16617
diff changeset
   149
                    objArrayHandle new_dependency,
2af47517ffbd 8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents: 16617
diff changeset
   150
                    Thread* THREAD);
2af47517ffbd 8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents: 16617
diff changeset
   151
   public:
2af47517ffbd 8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents: 16617
diff changeset
   152
    Dependencies() : _list_head(NULL) {}
17110
a8f03d38bde5 8013136: NPG: Parallel class loading tests fail after fix for JDK-8011802
mgerdin
parents: 17107
diff changeset
   153
    Dependencies(TRAPS) : _list_head(NULL) {
a8f03d38bde5 8013136: NPG: Parallel class loading tests fail after fix for JDK-8011802
mgerdin
parents: 17107
diff changeset
   154
      init(CHECK);
a8f03d38bde5 8013136: NPG: Parallel class loading tests fail after fix for JDK-8011802
mgerdin
parents: 17107
diff changeset
   155
    }
16684
2af47517ffbd 8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents: 16617
diff changeset
   156
    void add(Handle dependency, TRAPS);
2af47517ffbd 8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents: 16617
diff changeset
   157
    void init(TRAPS);
2af47517ffbd 8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents: 16617
diff changeset
   158
    void oops_do(OopClosure* f);
2af47517ffbd 8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents: 16617
diff changeset
   159
  };
2af47517ffbd 8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents: 16617
diff changeset
   160
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   161
  friend class ClassLoaderDataGraph;
25492
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   162
  friend class ClassLoaderDataGraphKlassIteratorAtomic;
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   163
  friend class ClassLoaderDataGraphMetaspaceIterator;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   164
  friend class MetaDataFactory;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   165
  friend class Method;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   166
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   167
  static ClassLoaderData * _the_null_class_loader_data;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   168
16684
2af47517ffbd 8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents: 16617
diff changeset
   169
  oop _class_loader;          // oop used to uniquely identify a class loader
2af47517ffbd 8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents: 16617
diff changeset
   170
                              // class loader or a canonical class path
2af47517ffbd 8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents: 16617
diff changeset
   171
  Dependencies _dependencies; // holds dependencies from this class loader
2af47517ffbd 8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents: 16617
diff changeset
   172
                              // data to others.
2af47517ffbd 8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents: 16617
diff changeset
   173
38937
2bf3c37c4841 8154750: Add missing OrderAccess operations to ClassLoaderData lock-free data structures
dholmes
parents: 38014
diff changeset
   174
  Metaspace * volatile _metaspace;  // Meta-space where meta-data defined by the
2bf3c37c4841 8154750: Add missing OrderAccess operations to ClassLoaderData lock-free data structures
dholmes
parents: 38014
diff changeset
   175
                                    // classes in the class loader are allocated.
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   176
  Mutex* _metaspace_lock;  // Locks the metaspace for allocations and setup.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   177
  bool _unloading;         // true if this class loader goes away
14816
f2935b95cb54 8004883: NPG: clean up anonymous class fix
coleenp
parents: 14588
diff changeset
   178
  bool _is_anonymous;      // if this CLD is for an anonymous class
38014
8731fa11f766 8152949: Jigsaw crash when Klass in _fixup_module_field_list is unloaded
lfoltan
parents: 36508
diff changeset
   179
  int _keep_alive;         // if this CLD is kept alive without a keep_alive_object().
8731fa11f766 8152949: Jigsaw crash when Klass in _fixup_module_field_list is unloaded
lfoltan
parents: 36508
diff changeset
   180
                           // Currently used solely for anonymous classes.
8731fa11f766 8152949: Jigsaw crash when Klass in _fixup_module_field_list is unloaded
lfoltan
parents: 36508
diff changeset
   181
                           // _keep_alive does not need to be volatile or
8731fa11f766 8152949: Jigsaw crash when Klass in _fixup_module_field_list is unloaded
lfoltan
parents: 36508
diff changeset
   182
                           // atomic since there is one unique CLD per anonymous class.
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   183
  volatile int _claimed;   // true if claimed, for example during GC traces.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   184
                           // To avoid applying oop closure more than once.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   185
                           // Has to be an int because we cas it.
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 35917
diff changeset
   186
  JNIHandleBlock* _handles; // Handles to constant pool arrays, Modules, etc, which
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 35917
diff changeset
   187
                            // have the same life cycle of the corresponding ClassLoader.
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   188
38937
2bf3c37c4841 8154750: Add missing OrderAccess operations to ClassLoaderData lock-free data structures
dholmes
parents: 38014
diff changeset
   189
  Klass* volatile _klasses;              // The classes defined by the class loader.
2bf3c37c4841 8154750: Add missing OrderAccess operations to ClassLoaderData lock-free data structures
dholmes
parents: 38014
diff changeset
   190
  PackageEntryTable* volatile _packages; // The packages defined by the class loader.
2bf3c37c4841 8154750: Add missing OrderAccess operations to ClassLoaderData lock-free data structures
dholmes
parents: 38014
diff changeset
   191
  ModuleEntryTable* volatile _modules;   // The modules defined by the class loader.
31046
d01ad7a0ecb0 8081320: Backout JDK-8059340: ConstantPool::_resolved_references is missing in heap dump
vlivanov
parents: 31038
diff changeset
   192
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   193
  // These method IDs are created for the class loader and set to NULL when the
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   194
  // class loader is unloaded.  They are rarely freed, only for redefine classes
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   195
  // and if they lose a data race in InstanceKlass.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   196
  JNIMethodBlock*                  _jmethod_ids;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   197
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   198
  // Metadata to be deallocated when it's safe at class unloading, when
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   199
  // this class loader isn't unloaded itself.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   200
  GrowableArray<Metadata*>*      _deallocate_list;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   201
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   202
  // Support for walking class loader data objects
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   203
  ClassLoaderData* _next; /// Next loader_datas created
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   204
34257
4be3504cc03b 8140802: Clean up and refactor of class loading code for CDS
iklam
parents: 31046
diff changeset
   205
  // CDS
4be3504cc03b 8140802: Clean up and refactor of class loading code for CDS
iklam
parents: 31046
diff changeset
   206
  int _shared_class_loader_id;
4be3504cc03b 8140802: Clean up and refactor of class loading code for CDS
iklam
parents: 31046
diff changeset
   207
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   208
  // ReadOnly and ReadWrite metaspaces (static because only on the null
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   209
  // class loader for now).
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   210
  static Metaspace* _ro_metaspace;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   211
  static Metaspace* _rw_metaspace;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   212
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   213
  void set_next(ClassLoaderData* next) { _next = next; }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   214
  ClassLoaderData* next() const        { return _next; }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   215
17110
a8f03d38bde5 8013136: NPG: Parallel class loading tests fail after fix for JDK-8011802
mgerdin
parents: 17107
diff changeset
   216
  ClassLoaderData(Handle h_class_loader, bool is_anonymous, Dependencies dependencies);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   217
  ~ClassLoaderData();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   218
31046
d01ad7a0ecb0 8081320: Backout JDK-8059340: ConstantPool::_resolved_references is missing in heap dump
vlivanov
parents: 31038
diff changeset
   219
  JNIHandleBlock* handles() const;
d01ad7a0ecb0 8081320: Backout JDK-8059340: ConstantPool::_resolved_references is missing in heap dump
vlivanov
parents: 31038
diff changeset
   220
  void set_handles(JNIHandleBlock* handles);
d01ad7a0ecb0 8081320: Backout JDK-8059340: ConstantPool::_resolved_references is missing in heap dump
vlivanov
parents: 31038
diff changeset
   221
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   222
  // GC interface.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   223
  void clear_claimed()          { _claimed = 0; }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   224
  bool claimed() const          { return _claimed == 1; }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   225
  bool claim();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   226
14588
8ec26d2d9339 8000662: NPG: nashorn ant clean test262 out-of-memory with Java heap
coleenp
parents: 13759
diff changeset
   227
  void unload();
38014
8731fa11f766 8152949: Jigsaw crash when Klass in _fixup_module_field_list is unloaded
lfoltan
parents: 36508
diff changeset
   228
  bool keep_alive() const       { return _keep_alive > 0; }
18025
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 17110
diff changeset
   229
  void classes_do(void f(Klass*));
21183
e148e499e5cd 8024423: JVMTI: GetLoadedClasses doesn't enumerate anonymous classes
farvidsson
parents: 18025
diff changeset
   230
  void loaded_classes_do(KlassClosure* klass_closure);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   231
  void classes_do(void f(InstanceKlass*));
23526
6851d341ad52 8037970: make PrintMethodData a diagnostic options
roland
parents: 22905
diff changeset
   232
  void methods_do(void f(Method*));
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 35917
diff changeset
   233
  void modules_do(void f(ModuleEntry*));
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 35917
diff changeset
   234
  void packages_do(void f(PackageEntry*));
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   235
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   236
  // Deallocate free list during class unloading.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   237
  void free_deallocate_list();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   238
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   239
  // Allocate out of this class loader data
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   240
  MetaWord* allocate(size_t size);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   241
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   242
 public:
25492
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   243
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   244
  bool is_alive(BoolObjectClosure* is_alive_closure) const;
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   245
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   246
  // Accessors
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   247
  Metaspace* metaspace_or_null() const     { return _metaspace; }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   248
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   249
  static ClassLoaderData* the_null_class_loader_data() {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   250
    return _the_null_class_loader_data;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   251
  }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   252
25325
e3af4e02b0d5 8026977: NPG: Remove ConstantPool::lock
coleenp
parents: 25051
diff changeset
   253
  Mutex* metaspace_lock() const { return _metaspace_lock; }
e3af4e02b0d5 8026977: NPG: Remove ConstantPool::lock
coleenp
parents: 25051
diff changeset
   254
14816
f2935b95cb54 8004883: NPG: clean up anonymous class fix
coleenp
parents: 14588
diff changeset
   255
  bool is_anonymous() const { return _is_anonymous; }
14588
8ec26d2d9339 8000662: NPG: nashorn ant clean test262 out-of-memory with Java heap
coleenp
parents: 13759
diff changeset
   256
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   257
  static void init_null_class_loader_data() {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   258
    assert(_the_null_class_loader_data == NULL, "cannot initialize twice");
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   259
    assert(ClassLoaderDataGraph::_head == NULL, "cannot initialize twice");
17110
a8f03d38bde5 8013136: NPG: Parallel class loading tests fail after fix for JDK-8011802
mgerdin
parents: 17107
diff changeset
   260
a8f03d38bde5 8013136: NPG: Parallel class loading tests fail after fix for JDK-8011802
mgerdin
parents: 17107
diff changeset
   261
    // We explicitly initialize the Dependencies object at a later phase in the initialization
a8f03d38bde5 8013136: NPG: Parallel class loading tests fail after fix for JDK-8011802
mgerdin
parents: 17107
diff changeset
   262
    _the_null_class_loader_data = new ClassLoaderData((oop)NULL, false, Dependencies());
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   263
    ClassLoaderDataGraph::_head = _the_null_class_loader_data;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   264
    assert(_the_null_class_loader_data->is_the_null_class_loader_data(), "Must be");
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   265
    if (DumpSharedSpaces) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   266
      _the_null_class_loader_data->initialize_shared_metaspaces();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   267
    }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   268
  }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   269
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   270
  bool is_the_null_class_loader_data() const {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   271
    return this == _the_null_class_loader_data;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   272
  }
39616
f82b1f888578 8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents: 38937
diff changeset
   273
  bool is_system_class_loader_data() const;
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 35917
diff changeset
   274
  bool is_platform_class_loader_data() const;
39616
f82b1f888578 8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents: 38937
diff changeset
   275
  bool is_builtin_class_loader_data() const;
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   276
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   277
  // The Metaspace is created lazily so may be NULL.  This
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   278
  // method will allocate a Metaspace if needed.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   279
  Metaspace* metaspace_non_null();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   280
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   281
  oop class_loader() const      { return _class_loader; }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   282
22900
e699fc9dc806 8035412: Cleanup ClassLoaderData::is_alive
stefank
parents: 22201
diff changeset
   283
  // The object the GC is using to keep this ClassLoaderData alive.
e699fc9dc806 8035412: Cleanup ClassLoaderData::is_alive
stefank
parents: 22201
diff changeset
   284
  oop keep_alive_object() const;
e699fc9dc806 8035412: Cleanup ClassLoaderData::is_alive
stefank
parents: 22201
diff changeset
   285
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   286
  // Returns true if this class loader data is for a loader going away.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   287
  bool is_unloading() const     {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   288
    assert(!(is_the_null_class_loader_data() && _unloading), "The null class loader can never be unloaded");
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   289
    return _unloading;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   290
  }
22900
e699fc9dc806 8035412: Cleanup ClassLoaderData::is_alive
stefank
parents: 22201
diff changeset
   291
38014
8731fa11f766 8152949: Jigsaw crash when Klass in _fixup_module_field_list is unloaded
lfoltan
parents: 36508
diff changeset
   292
  void inc_keep_alive();
8731fa11f766 8152949: Jigsaw crash when Klass in _fixup_module_field_list is unloaded
lfoltan
parents: 36508
diff changeset
   293
  void dec_keep_alive();
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   294
35498
392b50de06c6 8146401: Clean up oop.hpp: add inline directives and fix header files
goetz
parents: 34666
diff changeset
   295
  inline unsigned int identity_hash() const;
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   296
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   297
  // Used when tracing from klasses.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   298
  void oops_do(OopClosure* f, KlassClosure* klass_closure, bool must_claim);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   299
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   300
  void classes_do(KlassClosure* klass_closure);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   301
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   302
  JNIMethodBlock* jmethod_ids() const              { return _jmethod_ids; }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   303
  void set_jmethod_ids(JNIMethodBlock* new_block)  { _jmethod_ids = new_block; }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   304
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   305
  void print_value() { print_value_on(tty); }
15437
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 14848
diff changeset
   306
  void print_value_on(outputStream* out) const;
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   307
  void dump(outputStream * const out) PRODUCT_RETURN;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   308
  void verify();
14588
8ec26d2d9339 8000662: NPG: nashorn ant clean test262 out-of-memory with Java heap
coleenp
parents: 13759
diff changeset
   309
  const char* loader_name();
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   310
31046
d01ad7a0ecb0 8081320: Backout JDK-8059340: ConstantPool::_resolved_references is missing in heap dump
vlivanov
parents: 31038
diff changeset
   311
  jobject add_handle(Handle h);
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 35917
diff changeset
   312
  void remove_handle(jobject h);
34666
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents: 34257
diff changeset
   313
  void add_class(Klass* k, bool publicize = true);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   314
  void remove_class(Klass* k);
22794
f1c014ad3754 8027146: Class loading verification failure if GC occurs in Universe::flush_dependents_on
coleenp
parents: 22201
diff changeset
   315
  bool contains_klass(Klass* k);
34666
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents: 34257
diff changeset
   316
  void record_dependency(const Klass* to, TRAPS);
14588
8ec26d2d9339 8000662: NPG: nashorn ant clean test262 out-of-memory with Java heap
coleenp
parents: 13759
diff changeset
   317
  void init_dependencies(TRAPS);
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 35917
diff changeset
   318
  PackageEntryTable* packages();
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 35917
diff changeset
   319
  bool packages_defined() { return (_packages != NULL); }
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 35917
diff changeset
   320
  ModuleEntryTable* modules();
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 35917
diff changeset
   321
  bool modules_defined() { return (_modules != NULL); }
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   322
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   323
  void add_to_deallocate_list(Metadata* m);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   324
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   325
  static ClassLoaderData* class_loader_data(oop loader);
15847
f9ce2cd20dee 8008549: NPG: SystemDictionary::find(...) unnecessarily keeps class loaders alive
stefank
parents: 15437
diff changeset
   326
  static ClassLoaderData* class_loader_data_or_null(oop loader);
14588
8ec26d2d9339 8000662: NPG: nashorn ant clean test262 out-of-memory with Java heap
coleenp
parents: 13759
diff changeset
   327
  static ClassLoaderData* anonymous_class_loader_data(oop loader, TRAPS);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   328
  static void print_loader(ClassLoaderData *loader_data, outputStream *out);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   329
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   330
  // CDS support
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   331
  Metaspace* ro_metaspace();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   332
  Metaspace* rw_metaspace();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   333
  void initialize_shared_metaspaces();
34257
4be3504cc03b 8140802: Clean up and refactor of class loading code for CDS
iklam
parents: 31046
diff changeset
   334
34666
1c7168ea0034 8140485: Class load and creation cleanup
mgronlun
parents: 34257
diff changeset
   335
  int shared_class_loader_id() const {
34257
4be3504cc03b 8140802: Clean up and refactor of class loading code for CDS
iklam
parents: 31046
diff changeset
   336
    return _shared_class_loader_id;
4be3504cc03b 8140802: Clean up and refactor of class loading code for CDS
iklam
parents: 31046
diff changeset
   337
  }
4be3504cc03b 8140802: Clean up and refactor of class loading code for CDS
iklam
parents: 31046
diff changeset
   338
  void set_shared_class_loader_id(int id) {
4be3504cc03b 8140802: Clean up and refactor of class loading code for CDS
iklam
parents: 31046
diff changeset
   339
    assert(id >= 0, "sanity");
4be3504cc03b 8140802: Clean up and refactor of class loading code for CDS
iklam
parents: 31046
diff changeset
   340
    assert(_shared_class_loader_id <0, "cannot be assigned more than once");
4be3504cc03b 8140802: Clean up and refactor of class loading code for CDS
iklam
parents: 31046
diff changeset
   341
    _shared_class_loader_id = id;
4be3504cc03b 8140802: Clean up and refactor of class loading code for CDS
iklam
parents: 31046
diff changeset
   342
  }
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   343
};
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   344
25492
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   345
// An iterator that distributes Klasses to parallel worker threads.
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   346
class ClassLoaderDataGraphKlassIteratorAtomic : public StackObj {
29469
2213171cca5b 8074561: Wrong volatile qualifier for field ClassLoaderDataGraphKlassIteratorAtomic::_next_klass
asiebenborn
parents: 27673
diff changeset
   347
 Klass* volatile _next_klass;
25492
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   348
 public:
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   349
  ClassLoaderDataGraphKlassIteratorAtomic();
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   350
  Klass* next_klass();
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   351
 private:
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   352
  static Klass* next_klass_in_cldg(Klass* klass);
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   353
};
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   354
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   355
class ClassLoaderDataGraphMetaspaceIterator : public StackObj {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   356
  ClassLoaderData* _data;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   357
 public:
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   358
  ClassLoaderDataGraphMetaspaceIterator();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   359
  ~ClassLoaderDataGraphMetaspaceIterator();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   360
  bool repeat() { return _data != NULL; }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   361
  Metaspace* get_next() {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   362
    assert(_data != NULL, "Should not be NULL in call to the iterator");
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   363
    Metaspace* result = _data->metaspace_or_null();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   364
    _data = _data->next();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   365
    // This result might be NULL for class loaders without metaspace
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   366
    // yet.  It would be nice to return only non-null results but
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   367
    // there is no guarantee that there will be a non-null result
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   368
    // down the list so the caller is going to have to check.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   369
    return result;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   370
  }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   371
};
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   372
#endif // SHARE_VM_CLASSFILE_CLASSLOADERDATA_HPP