author | ccheung |
Thu, 13 Jun 2013 22:02:40 -0700 | |
changeset 18073 | f02460441ddc |
parent 18025 | b7bcf7497f93 |
child 21183 | e148e499e5cd |
permissions | -rw-r--r-- |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1 |
/* |
15437 | 2 |
* Copyright (c) 2012, 2013, 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 | 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" |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
34 |
|
18025 | 35 |
#if INCLUDE_TRACE |
36 |
# include "trace/traceTime.hpp" |
|
37 |
#endif |
|
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; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
54 |
class JNIHandleBlock; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
55 |
class Metadebug; |
18025 | 56 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
57 |
// GC root for walking class loader data created |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
58 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
59 |
class ClassLoaderDataGraph : public AllStatic { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
60 |
friend class ClassLoaderData; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
61 |
friend class ClassLoaderDataGraphMetaspaceIterator; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
62 |
friend class VMStructs; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
63 |
private: |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
64 |
// 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
|
65 |
static ClassLoaderData* _head; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
66 |
static ClassLoaderData* _unloading; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
67 |
// CMS support. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
68 |
static ClassLoaderData* _saved_head; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
69 |
|
17107
46fc21b30a1e
8011802: NPG: init_dependencies in class loader data graph can cause invalid CLD
mgerdin
parents:
16684
diff
changeset
|
70 |
static ClassLoaderData* add(Handle class_loader, bool anonymous, TRAPS); |
18025 | 71 |
static void post_class_unload_events(void); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
72 |
public: |
14588
8ec26d2d9339
8000662: NPG: nashorn ant clean test262 out-of-memory with Java heap
coleenp
parents:
13759
diff
changeset
|
73 |
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
|
74 |
static void purge(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
75 |
static void clear_claimed_marks(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
76 |
static 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
|
77 |
static void always_strong_oops_do(OopClosure* blk, KlassClosure* klass_closure, bool must_claim); |
14588
8ec26d2d9339
8000662: NPG: nashorn ant clean test262 out-of-memory with Java heap
coleenp
parents:
13759
diff
changeset
|
78 |
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
|
79 |
static void classes_do(KlassClosure* klass_closure); |
18025 | 80 |
static void classes_do(void f(Klass* const)); |
81 |
static void classes_unloading_do(void f(Klass* const)); |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
82 |
static bool do_unloading(BoolObjectClosure* is_alive); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
83 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
84 |
// CMS support. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
85 |
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
|
86 |
static GrowableArray<ClassLoaderData*>* new_clds(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
87 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
88 |
static void dump_on(outputStream * const out) PRODUCT_RETURN; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
89 |
static void dump() { dump_on(tty); } |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
90 |
static void verify(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
91 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
92 |
#ifndef PRODUCT |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
93 |
// expensive test for pointer in metaspace for debugging |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
94 |
static bool contains(address x); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
95 |
static bool contains_loader_data(ClassLoaderData* loader_data); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
96 |
#endif |
18025 | 97 |
|
98 |
#if INCLUDE_TRACE |
|
99 |
private: |
|
100 |
static TracingTime _class_unload_time; |
|
101 |
static void class_unload_event(Klass* const k); |
|
102 |
#endif |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
103 |
}; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
104 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
105 |
// ClassLoaderData class |
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 |
class ClassLoaderData : public CHeapObj<mtClass> { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
108 |
friend class VMStructs; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
109 |
private: |
16684
2af47517ffbd
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
16617
diff
changeset
|
110 |
class Dependencies VALUE_OBJ_CLASS_SPEC { |
2af47517ffbd
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
16617
diff
changeset
|
111 |
objArrayOop _list_head; |
2af47517ffbd
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
16617
diff
changeset
|
112 |
void locked_add(objArrayHandle last, |
2af47517ffbd
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
16617
diff
changeset
|
113 |
objArrayHandle new_dependency, |
2af47517ffbd
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
16617
diff
changeset
|
114 |
Thread* THREAD); |
2af47517ffbd
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
16617
diff
changeset
|
115 |
public: |
2af47517ffbd
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
16617
diff
changeset
|
116 |
Dependencies() : _list_head(NULL) {} |
17110
a8f03d38bde5
8013136: NPG: Parallel class loading tests fail after fix for JDK-8011802
mgerdin
parents:
17107
diff
changeset
|
117 |
Dependencies(TRAPS) : _list_head(NULL) { |
a8f03d38bde5
8013136: NPG: Parallel class loading tests fail after fix for JDK-8011802
mgerdin
parents:
17107
diff
changeset
|
118 |
init(CHECK); |
a8f03d38bde5
8013136: NPG: Parallel class loading tests fail after fix for JDK-8011802
mgerdin
parents:
17107
diff
changeset
|
119 |
} |
16684
2af47517ffbd
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
16617
diff
changeset
|
120 |
void add(Handle dependency, TRAPS); |
2af47517ffbd
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
16617
diff
changeset
|
121 |
void init(TRAPS); |
2af47517ffbd
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
16617
diff
changeset
|
122 |
void oops_do(OopClosure* f); |
2af47517ffbd
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
16617
diff
changeset
|
123 |
}; |
2af47517ffbd
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
16617
diff
changeset
|
124 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
125 |
friend class ClassLoaderDataGraph; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
126 |
friend class ClassLoaderDataGraphMetaspaceIterator; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
127 |
friend class MetaDataFactory; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
128 |
friend class Method; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
129 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
130 |
static ClassLoaderData * _the_null_class_loader_data; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
131 |
|
16684
2af47517ffbd
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
16617
diff
changeset
|
132 |
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
|
133 |
// class loader or a canonical class path |
2af47517ffbd
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
16617
diff
changeset
|
134 |
Dependencies _dependencies; // holds dependencies from this class loader |
2af47517ffbd
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
16617
diff
changeset
|
135 |
// data to others. |
2af47517ffbd
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
16617
diff
changeset
|
136 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
137 |
Metaspace * _metaspace; // Meta-space where meta-data defined by the |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
138 |
// classes in the class loader are allocated. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
139 |
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
|
140 |
bool _unloading; // true if this class loader goes away |
14588
8ec26d2d9339
8000662: NPG: nashorn ant clean test262 out-of-memory with Java heap
coleenp
parents:
13759
diff
changeset
|
141 |
bool _keep_alive; // if this CLD can be unloaded for anonymous loaders |
14816 | 142 |
bool _is_anonymous; // if this CLD is for an anonymous class |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
143 |
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
|
144 |
// To avoid applying oop closure more than once. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
145 |
// Has to be an int because we cas it. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
146 |
Klass* _klasses; // The classes defined by the class loader. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
147 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
148 |
JNIHandleBlock* _handles; // Handles to constant pool arrays |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
149 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
150 |
// 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
|
151 |
// 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
|
152 |
// and if they lose a data race in InstanceKlass. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
153 |
JNIMethodBlock* _jmethod_ids; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
154 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
155 |
// 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
|
156 |
// this class loader isn't unloaded itself. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
157 |
GrowableArray<Metadata*>* _deallocate_list; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
158 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
159 |
// Support for walking class loader data objects |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
160 |
ClassLoaderData* _next; /// Next loader_datas created |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
161 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
162 |
// 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
|
163 |
// class loader for now). |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
164 |
static Metaspace* _ro_metaspace; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
165 |
static Metaspace* _rw_metaspace; |
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 |
void set_next(ClassLoaderData* next) { _next = next; } |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
168 |
ClassLoaderData* next() const { return _next; } |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
169 |
|
17110
a8f03d38bde5
8013136: NPG: Parallel class loading tests fail after fix for JDK-8011802
mgerdin
parents:
17107
diff
changeset
|
170 |
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
|
171 |
~ClassLoaderData(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
172 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
173 |
void set_metaspace(Metaspace* m) { _metaspace = m; } |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
174 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
175 |
JNIHandleBlock* handles() const; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
176 |
void set_handles(JNIHandleBlock* handles); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
177 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
178 |
Mutex* metaspace_lock() const { return _metaspace_lock; } |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
179 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
180 |
// GC interface. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
181 |
void clear_claimed() { _claimed = 0; } |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
182 |
bool claimed() const { return _claimed == 1; } |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
183 |
bool claim(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
184 |
|
14588
8ec26d2d9339
8000662: NPG: nashorn ant clean test262 out-of-memory with Java heap
coleenp
parents:
13759
diff
changeset
|
185 |
void unload(); |
8ec26d2d9339
8000662: NPG: nashorn ant clean test262 out-of-memory with Java heap
coleenp
parents:
13759
diff
changeset
|
186 |
bool keep_alive() const { return _keep_alive; } |
8ec26d2d9339
8000662: NPG: nashorn ant clean test262 out-of-memory with Java heap
coleenp
parents:
13759
diff
changeset
|
187 |
bool is_alive(BoolObjectClosure* is_alive_closure) const; |
18025 | 188 |
void classes_do(void f(Klass*)); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
189 |
void classes_do(void f(InstanceKlass*)); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
190 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
191 |
// Deallocate free list during class unloading. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
192 |
void free_deallocate_list(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
193 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
194 |
// Allocate out of this class loader data |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
195 |
MetaWord* allocate(size_t size); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
196 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
197 |
public: |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
198 |
// Accessors |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
199 |
Metaspace* metaspace_or_null() const { return _metaspace; } |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
200 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
201 |
static ClassLoaderData* the_null_class_loader_data() { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
202 |
return _the_null_class_loader_data; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
203 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
204 |
|
14816 | 205 |
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
|
206 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
207 |
static void init_null_class_loader_data() { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
208 |
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
|
209 |
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
|
210 |
|
a8f03d38bde5
8013136: NPG: Parallel class loading tests fail after fix for JDK-8011802
mgerdin
parents:
17107
diff
changeset
|
211 |
// 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
|
212 |
_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
|
213 |
ClassLoaderDataGraph::_head = _the_null_class_loader_data; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
214 |
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
|
215 |
if (DumpSharedSpaces) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
216 |
_the_null_class_loader_data->initialize_shared_metaspaces(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
217 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
218 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
219 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
220 |
bool is_the_null_class_loader_data() const { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
221 |
return this == _the_null_class_loader_data; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
222 |
} |
16617
6235d2c7549f
7198429: need checked categorization of caller-sensitive methods in the JDK
twisti
parents:
15847
diff
changeset
|
223 |
bool is_ext_class_loader_data() const; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
224 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
225 |
// 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
|
226 |
// method will allocate a Metaspace if needed. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
227 |
Metaspace* metaspace_non_null(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
228 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
229 |
oop class_loader() const { return _class_loader; } |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
230 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
231 |
// 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
|
232 |
bool is_unloading() const { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
233 |
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
|
234 |
return _unloading; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
235 |
} |
14588
8ec26d2d9339
8000662: NPG: nashorn ant clean test262 out-of-memory with Java heap
coleenp
parents:
13759
diff
changeset
|
236 |
// Anonymous class loader data doesn't have anything to keep them from |
8ec26d2d9339
8000662: NPG: nashorn ant clean test262 out-of-memory with Java heap
coleenp
parents:
13759
diff
changeset
|
237 |
// being unloaded during parsing the anonymous class. |
8ec26d2d9339
8000662: NPG: nashorn ant clean test262 out-of-memory with Java heap
coleenp
parents:
13759
diff
changeset
|
238 |
void set_keep_alive(bool value) { _keep_alive = value; } |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
239 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
240 |
unsigned int identity_hash() { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
241 |
return _class_loader == NULL ? 0 : _class_loader->identity_hash(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
242 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
243 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
244 |
// Used when tracing from klasses. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
245 |
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
|
246 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
247 |
void classes_do(KlassClosure* klass_closure); |
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 |
JNIMethodBlock* jmethod_ids() const { return _jmethod_ids; } |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
250 |
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
|
251 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
252 |
void print_value() { print_value_on(tty); } |
15437 | 253 |
void print_value_on(outputStream* out) const; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
254 |
void dump(outputStream * const out) PRODUCT_RETURN; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
255 |
void verify(); |
14588
8ec26d2d9339
8000662: NPG: nashorn ant clean test262 out-of-memory with Java heap
coleenp
parents:
13759
diff
changeset
|
256 |
const char* loader_name(); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
257 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
258 |
jobject add_handle(Handle h); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
259 |
void add_class(Klass* k); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
260 |
void remove_class(Klass* k); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
261 |
void record_dependency(Klass* to, TRAPS); |
14588
8ec26d2d9339
8000662: NPG: nashorn ant clean test262 out-of-memory with Java heap
coleenp
parents:
13759
diff
changeset
|
262 |
void init_dependencies(TRAPS); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
263 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
264 |
void add_to_deallocate_list(Metadata* m); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
265 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
266 |
static ClassLoaderData* class_loader_data(oop loader); |
15847
f9ce2cd20dee
8008549: NPG: SystemDictionary::find(...) unnecessarily keeps class loaders alive
stefank
parents:
15437
diff
changeset
|
267 |
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
|
268 |
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
|
269 |
static void print_loader(ClassLoaderData *loader_data, outputStream *out); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
270 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
271 |
// CDS support |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
272 |
Metaspace* ro_metaspace(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
273 |
Metaspace* rw_metaspace(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
274 |
void initialize_shared_metaspaces(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
275 |
}; |
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 |
class ClassLoaderDataGraphMetaspaceIterator : public StackObj { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
278 |
ClassLoaderData* _data; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
279 |
public: |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
280 |
ClassLoaderDataGraphMetaspaceIterator(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
281 |
~ClassLoaderDataGraphMetaspaceIterator(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
282 |
bool repeat() { return _data != NULL; } |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
283 |
Metaspace* get_next() { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
284 |
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
|
285 |
Metaspace* result = _data->metaspace_or_null(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
286 |
_data = _data->next(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
287 |
// 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
|
288 |
// 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
|
289 |
// 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
|
290 |
// 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
|
291 |
return result; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
292 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
293 |
}; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
294 |
#endif // SHARE_VM_CLASSFILE_CLASSLOADERDATA_HPP |