author | naoto |
Tue, 09 Jul 2019 08:05:38 -0700 | |
changeset 55627 | 9c1885fb2a42 |
parent 55603 | 3868dde58ebb |
child 57603 | f9d9bed12d1a |
permissions | -rw-r--r-- |
51959
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
1 |
/* |
54355
f226ab0b7f21
8221183: Avoid code cache walk in MetadataOnStackMark
coleenp
parents:
53322
diff
changeset
|
2 |
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. |
51959
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
4 |
* |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
8 |
* |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
13 |
* accompanied this code). |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
14 |
* |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
18 |
* |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
21 |
* questions. |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
22 |
* |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
23 |
*/ |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
24 |
|
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
25 |
#include "precompiled.hpp" |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
26 |
#include "classfile/classLoaderDataGraph.inline.hpp" |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
27 |
#include "classfile/dictionary.hpp" |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
28 |
#include "classfile/javaClasses.hpp" |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
29 |
#include "classfile/metadataOnStackMark.hpp" |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
30 |
#include "classfile/moduleEntry.hpp" |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
31 |
#include "classfile/packageEntry.hpp" |
52781
436097b038a1
8213565: Crash in DependencyContext::remove_dependent_nmethod
eosterlund
parents:
52587
diff
changeset
|
32 |
#include "code/dependencyContext.hpp" |
51959
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
33 |
#include "logging/log.hpp" |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
34 |
#include "logging/logStream.hpp" |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
35 |
#include "memory/allocation.inline.hpp" |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
36 |
#include "memory/metaspace.hpp" |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
37 |
#include "memory/resourceArea.hpp" |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
38 |
#include "runtime/atomic.hpp" |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
39 |
#include "runtime/handles.inline.hpp" |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
40 |
#include "runtime/mutex.hpp" |
55268
c5fe45d1281d
8224151: Test vmTestbase/nsk/sysdict/vm/stress/chain/chain007/chain007.java might hang with release binaries
coleenp
parents:
54961
diff
changeset
|
41 |
#include "runtime/orderAccess.hpp" |
51959
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
42 |
#include "runtime/safepoint.hpp" |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
43 |
#include "runtime/safepointVerifiers.hpp" |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
44 |
#include "utilities/growableArray.hpp" |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
45 |
#include "utilities/macros.hpp" |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
46 |
#include "utilities/ostream.hpp" |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
47 |
|
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
48 |
volatile size_t ClassLoaderDataGraph::_num_array_classes = 0; |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
49 |
volatile size_t ClassLoaderDataGraph::_num_instance_classes = 0; |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
50 |
|
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
51 |
void ClassLoaderDataGraph::clear_claimed_marks() { |
55268
c5fe45d1281d
8224151: Test vmTestbase/nsk/sysdict/vm/stress/chain/chain007/chain007.java might hang with release binaries
coleenp
parents:
54961
diff
changeset
|
52 |
// The claimed marks of the CLDs in the ClassLoaderDataGraph are cleared |
c5fe45d1281d
8224151: Test vmTestbase/nsk/sysdict/vm/stress/chain/chain007/chain007.java might hang with release binaries
coleenp
parents:
54961
diff
changeset
|
53 |
// outside a safepoint and without locking the ClassLoaderDataGraph_lock. |
c5fe45d1281d
8224151: Test vmTestbase/nsk/sysdict/vm/stress/chain/chain007/chain007.java might hang with release binaries
coleenp
parents:
54961
diff
changeset
|
54 |
// This is required to avoid a deadlock between concurrent GC threads and safepointing. |
c5fe45d1281d
8224151: Test vmTestbase/nsk/sysdict/vm/stress/chain/chain007/chain007.java might hang with release binaries
coleenp
parents:
54961
diff
changeset
|
55 |
// |
c5fe45d1281d
8224151: Test vmTestbase/nsk/sysdict/vm/stress/chain/chain007/chain007.java might hang with release binaries
coleenp
parents:
54961
diff
changeset
|
56 |
// We need to make sure that the CLD contents are fully visible to the |
c5fe45d1281d
8224151: Test vmTestbase/nsk/sysdict/vm/stress/chain/chain007/chain007.java might hang with release binaries
coleenp
parents:
54961
diff
changeset
|
57 |
// reader thread. This is accomplished by acquire/release of the _head, |
c5fe45d1281d
8224151: Test vmTestbase/nsk/sysdict/vm/stress/chain/chain007/chain007.java might hang with release binaries
coleenp
parents:
54961
diff
changeset
|
58 |
// and is sufficient. |
c5fe45d1281d
8224151: Test vmTestbase/nsk/sysdict/vm/stress/chain/chain007/chain007.java might hang with release binaries
coleenp
parents:
54961
diff
changeset
|
59 |
// |
c5fe45d1281d
8224151: Test vmTestbase/nsk/sysdict/vm/stress/chain/chain007/chain007.java might hang with release binaries
coleenp
parents:
54961
diff
changeset
|
60 |
// Any ClassLoaderData added after or during walking the list are prepended to |
c5fe45d1281d
8224151: Test vmTestbase/nsk/sysdict/vm/stress/chain/chain007/chain007.java might hang with release binaries
coleenp
parents:
54961
diff
changeset
|
61 |
// _head. Their claim mark need not be handled here. |
c5fe45d1281d
8224151: Test vmTestbase/nsk/sysdict/vm/stress/chain/chain007/chain007.java might hang with release binaries
coleenp
parents:
54961
diff
changeset
|
62 |
for (ClassLoaderData* cld = OrderAccess::load_acquire(&_head); cld != NULL; cld = cld->next()) { |
52141
de6dc206a92b
8210330: Make CLD claiming allow multiple claim bits
eosterlund
parents:
52140
diff
changeset
|
63 |
cld->clear_claim(); |
51959
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
64 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
65 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
66 |
|
55603
3868dde58ebb
8227175: ZGC: ZHeapIterator visits potentially dead objects
stefank
parents:
55268
diff
changeset
|
67 |
void ClassLoaderDataGraph::clear_claimed_marks(int claim) { |
3868dde58ebb
8227175: ZGC: ZHeapIterator visits potentially dead objects
stefank
parents:
55268
diff
changeset
|
68 |
for (ClassLoaderData* cld = OrderAccess::load_acquire(&_head); cld != NULL; cld = cld->next()) { |
3868dde58ebb
8227175: ZGC: ZHeapIterator visits potentially dead objects
stefank
parents:
55268
diff
changeset
|
69 |
cld->clear_claim(claim); |
3868dde58ebb
8227175: ZGC: ZHeapIterator visits potentially dead objects
stefank
parents:
55268
diff
changeset
|
70 |
} |
3868dde58ebb
8227175: ZGC: ZHeapIterator visits potentially dead objects
stefank
parents:
55268
diff
changeset
|
71 |
} |
51959
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
72 |
// Class iterator used by the compiler. It gets some number of classes at |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
73 |
// a safepoint to decay invocation counters on the methods. |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
74 |
class ClassLoaderDataGraphKlassIteratorStatic { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
75 |
ClassLoaderData* _current_loader_data; |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
76 |
Klass* _current_class_entry; |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
77 |
public: |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
78 |
|
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
79 |
ClassLoaderDataGraphKlassIteratorStatic() : _current_loader_data(NULL), _current_class_entry(NULL) {} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
80 |
|
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
81 |
InstanceKlass* try_get_next_class() { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
82 |
assert(SafepointSynchronize::is_at_safepoint(), "only called at safepoint"); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
83 |
size_t max_classes = ClassLoaderDataGraph::num_instance_classes(); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
84 |
assert(max_classes > 0, "should not be called with no instance classes"); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
85 |
for (size_t i = 0; i < max_classes; ) { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
86 |
|
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
87 |
if (_current_class_entry != NULL) { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
88 |
Klass* k = _current_class_entry; |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
89 |
_current_class_entry = _current_class_entry->next_link(); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
90 |
|
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
91 |
if (k->is_instance_klass()) { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
92 |
InstanceKlass* ik = InstanceKlass::cast(k); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
93 |
i++; // count all instance classes found |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
94 |
// Not yet loaded classes are counted in max_classes |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
95 |
// but only return loaded classes. |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
96 |
if (ik->is_loaded()) { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
97 |
return ik; |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
98 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
99 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
100 |
} else { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
101 |
// Go to next CLD |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
102 |
if (_current_loader_data != NULL) { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
103 |
_current_loader_data = _current_loader_data->next(); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
104 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
105 |
// Start at the beginning |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
106 |
if (_current_loader_data == NULL) { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
107 |
_current_loader_data = ClassLoaderDataGraph::_head; |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
108 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
109 |
|
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
110 |
_current_class_entry = _current_loader_data->klasses(); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
111 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
112 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
113 |
// Should never be reached unless all instance classes have failed or are not fully loaded. |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
114 |
// Caller handles NULL. |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
115 |
return NULL; |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
116 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
117 |
|
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
118 |
// If the current class for the static iterator is a class being unloaded or |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
119 |
// deallocated, adjust the current class. |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
120 |
void adjust_saved_class(ClassLoaderData* cld) { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
121 |
if (_current_loader_data == cld) { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
122 |
_current_loader_data = cld->next(); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
123 |
if (_current_loader_data != NULL) { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
124 |
_current_class_entry = _current_loader_data->klasses(); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
125 |
} // else try_get_next_class will start at the head |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
126 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
127 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
128 |
|
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
129 |
void adjust_saved_class(Klass* klass) { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
130 |
if (_current_class_entry == klass) { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
131 |
_current_class_entry = klass->next_link(); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
132 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
133 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
134 |
}; |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
135 |
|
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
136 |
static ClassLoaderDataGraphKlassIteratorStatic static_klass_iterator; |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
137 |
|
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
138 |
InstanceKlass* ClassLoaderDataGraph::try_get_next_class() { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
139 |
assert(SafepointSynchronize::is_at_safepoint(), "only called at safepoint"); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
140 |
return static_klass_iterator.try_get_next_class(); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
141 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
142 |
|
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
143 |
void ClassLoaderDataGraph::adjust_saved_class(ClassLoaderData* cld) { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
144 |
return static_klass_iterator.adjust_saved_class(cld); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
145 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
146 |
|
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
147 |
void ClassLoaderDataGraph::adjust_saved_class(Klass* klass) { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
148 |
return static_klass_iterator.adjust_saved_class(klass); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
149 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
150 |
|
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
151 |
void ClassLoaderDataGraph::clean_deallocate_lists(bool walk_previous_versions) { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
152 |
assert(SafepointSynchronize::is_at_safepoint(), "must only be called at safepoint"); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
153 |
uint loaders_processed = 0; |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
154 |
for (ClassLoaderData* cld = _head; cld != NULL; cld = cld->next()) { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
155 |
// is_alive check will be necessary for concurrent class unloading. |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
156 |
if (cld->is_alive()) { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
157 |
// clean metaspace |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
158 |
if (walk_previous_versions) { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
159 |
cld->classes_do(InstanceKlass::purge_previous_versions); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
160 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
161 |
cld->free_deallocate_list(); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
162 |
loaders_processed++; |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
163 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
164 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
165 |
log_debug(class, loader, data)("clean_deallocate_lists: loaders processed %u %s", |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
166 |
loaders_processed, walk_previous_versions ? "walk_previous_versions" : ""); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
167 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
168 |
|
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
169 |
void ClassLoaderDataGraph::walk_metadata_and_clean_metaspaces() { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
170 |
assert(SafepointSynchronize::is_at_safepoint(), "must only be called at safepoint"); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
171 |
|
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
172 |
_should_clean_deallocate_lists = false; // assume everything gets cleaned |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
173 |
|
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
174 |
// Mark metadata seen on the stack so we can delete unreferenced entries. |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
175 |
// Walk all metadata, including the expensive code cache walk, only for class redefinition. |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
176 |
// The MetadataOnStackMark walk during redefinition saves previous versions if it finds old methods |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
177 |
// on the stack or in the code cache, so we only have to repeat the full walk if |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
178 |
// they were found at that time. |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
179 |
// TODO: have redefinition clean old methods out of the code cache. They still exist in some places. |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
180 |
bool walk_all_metadata = InstanceKlass::has_previous_versions_and_reset(); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
181 |
|
54355
f226ab0b7f21
8221183: Avoid code cache walk in MetadataOnStackMark
coleenp
parents:
53322
diff
changeset
|
182 |
MetadataOnStackMark md_on_stack(walk_all_metadata, /*redefinition_walk*/false); |
51959
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
183 |
clean_deallocate_lists(walk_all_metadata); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
184 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
185 |
|
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
186 |
// GC root of class loader data created. |
55268
c5fe45d1281d
8224151: Test vmTestbase/nsk/sysdict/vm/stress/chain/chain007/chain007.java might hang with release binaries
coleenp
parents:
54961
diff
changeset
|
187 |
ClassLoaderData* volatile ClassLoaderDataGraph::_head = NULL; |
51959
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
188 |
ClassLoaderData* ClassLoaderDataGraph::_unloading = NULL; |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
189 |
ClassLoaderData* ClassLoaderDataGraph::_saved_unloading = NULL; |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
190 |
ClassLoaderData* ClassLoaderDataGraph::_saved_head = NULL; |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
191 |
|
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
192 |
bool ClassLoaderDataGraph::_should_purge = false; |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
193 |
bool ClassLoaderDataGraph::_should_clean_deallocate_lists = false; |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
194 |
bool ClassLoaderDataGraph::_safepoint_cleanup_needed = false; |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
195 |
bool ClassLoaderDataGraph::_metaspace_oom = false; |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
196 |
|
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
197 |
// Add a new class loader data node to the list. Assign the newly created |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
198 |
// ClassLoaderData into the java/lang/ClassLoader object as a hidden field |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
199 |
ClassLoaderData* ClassLoaderDataGraph::add_to_graph(Handle loader, bool is_unsafe_anonymous) { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
200 |
|
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
201 |
assert_lock_strong(ClassLoaderDataGraph_lock); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
202 |
|
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
203 |
ClassLoaderData* cld; |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
204 |
|
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
205 |
// First check if another thread beat us to creating the CLD and installing |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
206 |
// it into the loader while we were waiting for the lock. |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
207 |
if (!is_unsafe_anonymous && loader.not_null()) { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
208 |
cld = java_lang_ClassLoader::loader_data_acquire(loader()); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
209 |
if (cld != NULL) { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
210 |
return cld; |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
211 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
212 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
213 |
|
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
214 |
// We mustn't GC until we've installed the ClassLoaderData in the Graph since the CLD |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
215 |
// contains oops in _handles that must be walked. GC doesn't walk CLD from the |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
216 |
// loader oop in all collections, particularly young collections. |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
217 |
NoSafepointVerifier no_safepoints; |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
218 |
|
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
219 |
cld = new ClassLoaderData(loader, is_unsafe_anonymous); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
220 |
|
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
221 |
// First install the new CLD to the Graph. |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
222 |
cld->set_next(_head); |
55268
c5fe45d1281d
8224151: Test vmTestbase/nsk/sysdict/vm/stress/chain/chain007/chain007.java might hang with release binaries
coleenp
parents:
54961
diff
changeset
|
223 |
OrderAccess::release_store(&_head, cld); |
51959
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
224 |
|
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
225 |
// Next associate with the class_loader. |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
226 |
if (!is_unsafe_anonymous) { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
227 |
// Use OrderAccess, since readers need to get the loader_data only after |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
228 |
// it's added to the Graph |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
229 |
java_lang_ClassLoader::release_set_loader_data(loader(), cld); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
230 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
231 |
|
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
232 |
// Lastly log, if requested |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
233 |
LogTarget(Trace, class, loader, data) lt; |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
234 |
if (lt.is_enabled()) { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
235 |
ResourceMark rm; |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
236 |
LogStream ls(lt); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
237 |
ls.print("create "); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
238 |
cld->print_value_on(&ls); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
239 |
ls.cr(); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
240 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
241 |
return cld; |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
242 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
243 |
|
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
244 |
ClassLoaderData* ClassLoaderDataGraph::add(Handle loader, bool is_unsafe_anonymous) { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
245 |
MutexLocker ml(ClassLoaderDataGraph_lock); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
246 |
ClassLoaderData* loader_data = add_to_graph(loader, is_unsafe_anonymous); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
247 |
return loader_data; |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
248 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
249 |
|
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
250 |
void ClassLoaderDataGraph::cld_unloading_do(CLDClosure* cl) { |
52140
3a168f782e80
8210064: ZGC: Introduce ZConcurrentRootsIterator for scanning a subset of strong IN_NATIVE roots concurrently
eosterlund
parents:
52014
diff
changeset
|
251 |
assert_locked_or_safepoint_weak(ClassLoaderDataGraph_lock); |
51959
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
252 |
// Only walk the head until any clds not purged from prior unloading |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
253 |
// (CMS doesn't purge right away). |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
254 |
for (ClassLoaderData* cld = _unloading; cld != _saved_unloading; cld = cld->next()) { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
255 |
assert(cld->is_unloading(), "invariant"); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
256 |
cl->do_cld(cld); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
257 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
258 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
259 |
|
52586
74109912c738
8213751: ClassLoaderDataGraph::cld_do() should sometimes require CLDG_lock
coleenp
parents:
52498
diff
changeset
|
260 |
// These are functions called by the GC, which require all of the CLDs, including the |
74109912c738
8213751: ClassLoaderDataGraph::cld_do() should sometimes require CLDG_lock
coleenp
parents:
52498
diff
changeset
|
261 |
// unloading ones. |
74109912c738
8213751: ClassLoaderDataGraph::cld_do() should sometimes require CLDG_lock
coleenp
parents:
52498
diff
changeset
|
262 |
void ClassLoaderDataGraph::cld_do(CLDClosure* cl) { |
74109912c738
8213751: ClassLoaderDataGraph::cld_do() should sometimes require CLDG_lock
coleenp
parents:
52498
diff
changeset
|
263 |
assert_locked_or_safepoint_weak(ClassLoaderDataGraph_lock); |
74109912c738
8213751: ClassLoaderDataGraph::cld_do() should sometimes require CLDG_lock
coleenp
parents:
52498
diff
changeset
|
264 |
for (ClassLoaderData* cld = _head; cld != NULL; cld = cld->_next) { |
74109912c738
8213751: ClassLoaderDataGraph::cld_do() should sometimes require CLDG_lock
coleenp
parents:
52498
diff
changeset
|
265 |
cl->do_cld(cld); |
74109912c738
8213751: ClassLoaderDataGraph::cld_do() should sometimes require CLDG_lock
coleenp
parents:
52498
diff
changeset
|
266 |
} |
74109912c738
8213751: ClassLoaderDataGraph::cld_do() should sometimes require CLDG_lock
coleenp
parents:
52498
diff
changeset
|
267 |
} |
74109912c738
8213751: ClassLoaderDataGraph::cld_do() should sometimes require CLDG_lock
coleenp
parents:
52498
diff
changeset
|
268 |
|
51959
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
269 |
void ClassLoaderDataGraph::roots_cld_do(CLDClosure* strong, CLDClosure* weak) { |
52140
3a168f782e80
8210064: ZGC: Introduce ZConcurrentRootsIterator for scanning a subset of strong IN_NATIVE roots concurrently
eosterlund
parents:
52014
diff
changeset
|
270 |
assert_locked_or_safepoint_weak(ClassLoaderDataGraph_lock); |
51959
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
271 |
for (ClassLoaderData* cld = _head; cld != NULL; cld = cld->_next) { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
272 |
CLDClosure* closure = cld->keep_alive() ? strong : weak; |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
273 |
if (closure != NULL) { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
274 |
closure->do_cld(cld); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
275 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
276 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
277 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
278 |
|
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
279 |
void ClassLoaderDataGraph::always_strong_cld_do(CLDClosure* cl) { |
52140
3a168f782e80
8210064: ZGC: Introduce ZConcurrentRootsIterator for scanning a subset of strong IN_NATIVE roots concurrently
eosterlund
parents:
52014
diff
changeset
|
280 |
assert_locked_or_safepoint_weak(ClassLoaderDataGraph_lock); |
51959
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
281 |
if (ClassUnloading) { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
282 |
roots_cld_do(cl, NULL); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
283 |
} else { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
284 |
cld_do(cl); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
285 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
286 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
287 |
|
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
288 |
// Closure for locking and iterating through classes. |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
289 |
LockedClassesDo::LockedClassesDo(classes_do_func_t f) : _function(f) { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
290 |
ClassLoaderDataGraph_lock->lock(); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
291 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
292 |
|
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
293 |
LockedClassesDo::LockedClassesDo() : _function(NULL) { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
294 |
// callers provide their own do_klass |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
295 |
ClassLoaderDataGraph_lock->lock(); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
296 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
297 |
|
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
298 |
LockedClassesDo::~LockedClassesDo() { ClassLoaderDataGraph_lock->unlock(); } |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
299 |
|
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
300 |
|
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
301 |
// Iterating over the CLDG needs to be locked because |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
302 |
// unloading can remove entries concurrently soon. |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
303 |
class ClassLoaderDataGraphIterator : public StackObj { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
304 |
ClassLoaderData* _next; |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
305 |
HandleMark _hm; // clean up handles when this is done. |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
306 |
Handle _holder; |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
307 |
Thread* _thread; |
52586
74109912c738
8213751: ClassLoaderDataGraph::cld_do() should sometimes require CLDG_lock
coleenp
parents:
52498
diff
changeset
|
308 |
NoSafepointVerifier _nsv; // No safepoints allowed in this scope |
74109912c738
8213751: ClassLoaderDataGraph::cld_do() should sometimes require CLDG_lock
coleenp
parents:
52498
diff
changeset
|
309 |
// unless verifying at a safepoint. |
51959
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
310 |
|
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
311 |
public: |
52586
74109912c738
8213751: ClassLoaderDataGraph::cld_do() should sometimes require CLDG_lock
coleenp
parents:
52498
diff
changeset
|
312 |
ClassLoaderDataGraphIterator() : _next(ClassLoaderDataGraph::_head), |
74109912c738
8213751: ClassLoaderDataGraph::cld_do() should sometimes require CLDG_lock
coleenp
parents:
52498
diff
changeset
|
313 |
_nsv(true, !SafepointSynchronize::is_at_safepoint()) { |
51959
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
314 |
_thread = Thread::current(); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
315 |
assert_locked_or_safepoint(ClassLoaderDataGraph_lock); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
316 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
317 |
|
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
318 |
ClassLoaderData* get_next() { |
52344
55711b181dfc
8213107: Make ClassLoaderDataGraph iterator skip unloaded CLDs
coleenp
parents:
52141
diff
changeset
|
319 |
ClassLoaderData* cld = _next; |
55711b181dfc
8213107: Make ClassLoaderDataGraph iterator skip unloaded CLDs
coleenp
parents:
52141
diff
changeset
|
320 |
// Skip already unloaded CLD for concurrent unloading. |
55711b181dfc
8213107: Make ClassLoaderDataGraph iterator skip unloaded CLDs
coleenp
parents:
52141
diff
changeset
|
321 |
while (cld != NULL && !cld->is_alive()) { |
55711b181dfc
8213107: Make ClassLoaderDataGraph iterator skip unloaded CLDs
coleenp
parents:
52141
diff
changeset
|
322 |
cld = cld->next(); |
51959
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
323 |
} |
52344
55711b181dfc
8213107: Make ClassLoaderDataGraph iterator skip unloaded CLDs
coleenp
parents:
52141
diff
changeset
|
324 |
if (cld != NULL) { |
55711b181dfc
8213107: Make ClassLoaderDataGraph iterator skip unloaded CLDs
coleenp
parents:
52141
diff
changeset
|
325 |
// Keep cld that is being returned alive. |
55711b181dfc
8213107: Make ClassLoaderDataGraph iterator skip unloaded CLDs
coleenp
parents:
52141
diff
changeset
|
326 |
_holder = Handle(_thread, cld->holder_phantom()); |
55711b181dfc
8213107: Make ClassLoaderDataGraph iterator skip unloaded CLDs
coleenp
parents:
52141
diff
changeset
|
327 |
_next = cld->next(); |
55711b181dfc
8213107: Make ClassLoaderDataGraph iterator skip unloaded CLDs
coleenp
parents:
52141
diff
changeset
|
328 |
} else { |
55711b181dfc
8213107: Make ClassLoaderDataGraph iterator skip unloaded CLDs
coleenp
parents:
52141
diff
changeset
|
329 |
_next = NULL; |
55711b181dfc
8213107: Make ClassLoaderDataGraph iterator skip unloaded CLDs
coleenp
parents:
52141
diff
changeset
|
330 |
} |
55711b181dfc
8213107: Make ClassLoaderDataGraph iterator skip unloaded CLDs
coleenp
parents:
52141
diff
changeset
|
331 |
return cld; |
51959
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
332 |
} |
52586
74109912c738
8213751: ClassLoaderDataGraph::cld_do() should sometimes require CLDG_lock
coleenp
parents:
52498
diff
changeset
|
333 |
}; |
52344
55711b181dfc
8213107: Make ClassLoaderDataGraph iterator skip unloaded CLDs
coleenp
parents:
52141
diff
changeset
|
334 |
|
52586
74109912c738
8213751: ClassLoaderDataGraph::cld_do() should sometimes require CLDG_lock
coleenp
parents:
52498
diff
changeset
|
335 |
void ClassLoaderDataGraph::loaded_cld_do(CLDClosure* cl) { |
74109912c738
8213751: ClassLoaderDataGraph::cld_do() should sometimes require CLDG_lock
coleenp
parents:
52498
diff
changeset
|
336 |
ClassLoaderDataGraphIterator iter; |
74109912c738
8213751: ClassLoaderDataGraph::cld_do() should sometimes require CLDG_lock
coleenp
parents:
52498
diff
changeset
|
337 |
while (ClassLoaderData* cld = iter.get_next()) { |
74109912c738
8213751: ClassLoaderDataGraph::cld_do() should sometimes require CLDG_lock
coleenp
parents:
52498
diff
changeset
|
338 |
cl->do_cld(cld); |
74109912c738
8213751: ClassLoaderDataGraph::cld_do() should sometimes require CLDG_lock
coleenp
parents:
52498
diff
changeset
|
339 |
} |
74109912c738
8213751: ClassLoaderDataGraph::cld_do() should sometimes require CLDG_lock
coleenp
parents:
52498
diff
changeset
|
340 |
} |
51959
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
341 |
|
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
342 |
// These functions assume that the caller has locked the ClassLoaderDataGraph_lock |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
343 |
// if they are not calling the function from a safepoint. |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
344 |
void ClassLoaderDataGraph::classes_do(KlassClosure* klass_closure) { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
345 |
ClassLoaderDataGraphIterator iter; |
52344
55711b181dfc
8213107: Make ClassLoaderDataGraph iterator skip unloaded CLDs
coleenp
parents:
52141
diff
changeset
|
346 |
while (ClassLoaderData* cld = iter.get_next()) { |
51959
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
347 |
cld->classes_do(klass_closure); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
348 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
349 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
350 |
|
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
351 |
void ClassLoaderDataGraph::classes_do(void f(Klass* const)) { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
352 |
ClassLoaderDataGraphIterator iter; |
52344
55711b181dfc
8213107: Make ClassLoaderDataGraph iterator skip unloaded CLDs
coleenp
parents:
52141
diff
changeset
|
353 |
while (ClassLoaderData* cld = iter.get_next()) { |
51959
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
354 |
cld->classes_do(f); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
355 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
356 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
357 |
|
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
358 |
void ClassLoaderDataGraph::methods_do(void f(Method*)) { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
359 |
ClassLoaderDataGraphIterator iter; |
52344
55711b181dfc
8213107: Make ClassLoaderDataGraph iterator skip unloaded CLDs
coleenp
parents:
52141
diff
changeset
|
360 |
while (ClassLoaderData* cld = iter.get_next()) { |
51959
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
361 |
cld->methods_do(f); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
362 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
363 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
364 |
|
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
365 |
void ClassLoaderDataGraph::modules_do(void f(ModuleEntry*)) { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
366 |
assert_locked_or_safepoint(Module_lock); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
367 |
ClassLoaderDataGraphIterator iter; |
52344
55711b181dfc
8213107: Make ClassLoaderDataGraph iterator skip unloaded CLDs
coleenp
parents:
52141
diff
changeset
|
368 |
while (ClassLoaderData* cld = iter.get_next()) { |
51959
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
369 |
cld->modules_do(f); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
370 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
371 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
372 |
|
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
373 |
void ClassLoaderDataGraph::modules_unloading_do(void f(ModuleEntry*)) { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
374 |
assert_locked_or_safepoint(ClassLoaderDataGraph_lock); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
375 |
// Only walk the head until any clds not purged from prior unloading |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
376 |
// (CMS doesn't purge right away). |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
377 |
for (ClassLoaderData* cld = _unloading; cld != _saved_unloading; cld = cld->next()) { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
378 |
assert(cld->is_unloading(), "invariant"); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
379 |
cld->modules_do(f); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
380 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
381 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
382 |
|
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
383 |
void ClassLoaderDataGraph::packages_do(void f(PackageEntry*)) { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
384 |
assert_locked_or_safepoint(Module_lock); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
385 |
ClassLoaderDataGraphIterator iter; |
52344
55711b181dfc
8213107: Make ClassLoaderDataGraph iterator skip unloaded CLDs
coleenp
parents:
52141
diff
changeset
|
386 |
while (ClassLoaderData* cld = iter.get_next()) { |
51959
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
387 |
cld->packages_do(f); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
388 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
389 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
390 |
|
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
391 |
void ClassLoaderDataGraph::packages_unloading_do(void f(PackageEntry*)) { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
392 |
assert_locked_or_safepoint(ClassLoaderDataGraph_lock); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
393 |
// Only walk the head until any clds not purged from prior unloading |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
394 |
// (CMS doesn't purge right away). |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
395 |
for (ClassLoaderData* cld = _unloading; cld != _saved_unloading; cld = cld->next()) { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
396 |
assert(cld->is_unloading(), "invariant"); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
397 |
cld->packages_do(f); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
398 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
399 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
400 |
|
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
401 |
void ClassLoaderDataGraph::loaded_classes_do(KlassClosure* klass_closure) { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
402 |
ClassLoaderDataGraphIterator iter; |
52344
55711b181dfc
8213107: Make ClassLoaderDataGraph iterator skip unloaded CLDs
coleenp
parents:
52141
diff
changeset
|
403 |
while (ClassLoaderData* cld = iter.get_next()) { |
51959
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
404 |
cld->loaded_classes_do(klass_closure); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
405 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
406 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
407 |
|
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
408 |
// This case can block but cannot do unloading (called from CDS) |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
409 |
void ClassLoaderDataGraph::unlocked_loaded_classes_do(KlassClosure* klass_closure) { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
410 |
for (ClassLoaderData* cld = _head; cld != NULL; cld = cld->next()) { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
411 |
cld->loaded_classes_do(klass_closure); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
412 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
413 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
414 |
|
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
415 |
|
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
416 |
void ClassLoaderDataGraph::classes_unloading_do(void f(Klass* const)) { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
417 |
assert_locked_or_safepoint(ClassLoaderDataGraph_lock); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
418 |
// Only walk the head until any clds not purged from prior unloading |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
419 |
// (CMS doesn't purge right away). |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
420 |
for (ClassLoaderData* cld = _unloading; cld != _saved_unloading; cld = cld->next()) { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
421 |
assert(cld->is_unloading(), "invariant"); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
422 |
cld->classes_do(f); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
423 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
424 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
425 |
|
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
426 |
#define FOR_ALL_DICTIONARY(X) ClassLoaderDataGraphIterator iter; \ |
52344
55711b181dfc
8213107: Make ClassLoaderDataGraph iterator skip unloaded CLDs
coleenp
parents:
52141
diff
changeset
|
427 |
while (ClassLoaderData* X = iter.get_next()) \ |
51959
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
428 |
if (X->dictionary() != NULL) |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
429 |
|
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
430 |
// Walk classes in the loaded class dictionaries in various forms. |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
431 |
// Only walks the classes defined in this class loader. |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
432 |
void ClassLoaderDataGraph::dictionary_classes_do(void f(InstanceKlass*)) { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
433 |
FOR_ALL_DICTIONARY(cld) { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
434 |
cld->dictionary()->classes_do(f); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
435 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
436 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
437 |
|
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
438 |
// Only walks the classes defined in this class loader. |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
439 |
void ClassLoaderDataGraph::dictionary_classes_do(void f(InstanceKlass*, TRAPS), TRAPS) { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
440 |
FOR_ALL_DICTIONARY(cld) { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
441 |
cld->dictionary()->classes_do(f, CHECK); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
442 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
443 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
444 |
|
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
445 |
void ClassLoaderDataGraph::verify_dictionary() { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
446 |
FOR_ALL_DICTIONARY(cld) { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
447 |
cld->dictionary()->verify(); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
448 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
449 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
450 |
|
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
451 |
void ClassLoaderDataGraph::print_dictionary(outputStream* st) { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
452 |
FOR_ALL_DICTIONARY(cld) { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
453 |
st->print("Dictionary for "); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
454 |
cld->print_value_on(st); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
455 |
st->cr(); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
456 |
cld->dictionary()->print_on(st); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
457 |
st->cr(); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
458 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
459 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
460 |
|
54764 | 461 |
void ClassLoaderDataGraph::print_table_statistics(outputStream* st) { |
51959
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
462 |
FOR_ALL_DICTIONARY(cld) { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
463 |
ResourceMark rm; |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
464 |
stringStream tempst; |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
465 |
tempst.print("System Dictionary for %s class loader", cld->loader_name_and_id()); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
466 |
cld->dictionary()->print_table_statistics(st, tempst.as_string()); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
467 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
468 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
469 |
|
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
470 |
GrowableArray<ClassLoaderData*>* ClassLoaderDataGraph::new_clds() { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
471 |
assert_locked_or_safepoint(ClassLoaderDataGraph_lock); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
472 |
assert(_head == NULL || _saved_head != NULL, "remember_new_clds(true) not called?"); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
473 |
|
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
474 |
GrowableArray<ClassLoaderData*>* array = new GrowableArray<ClassLoaderData*>(); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
475 |
|
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
476 |
// The CLDs in [_head, _saved_head] were all added during last call to remember_new_clds(true); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
477 |
ClassLoaderData* curr = _head; |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
478 |
while (curr != _saved_head) { |
55603
3868dde58ebb
8227175: ZGC: ZHeapIterator visits potentially dead objects
stefank
parents:
55268
diff
changeset
|
479 |
if (!curr->claimed(ClassLoaderData::_claim_strong)) { |
51959
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
480 |
array->push(curr); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
481 |
LogTarget(Debug, class, loader, data) lt; |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
482 |
if (lt.is_enabled()) { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
483 |
LogStream ls(lt); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
484 |
ls.print("found new CLD: "); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
485 |
curr->print_value_on(&ls); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
486 |
ls.cr(); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
487 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
488 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
489 |
|
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
490 |
curr = curr->_next; |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
491 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
492 |
|
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
493 |
return array; |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
494 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
495 |
|
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
496 |
#ifndef PRODUCT |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
497 |
bool ClassLoaderDataGraph::contains_loader_data(ClassLoaderData* loader_data) { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
498 |
assert_locked_or_safepoint(ClassLoaderDataGraph_lock); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
499 |
for (ClassLoaderData* data = _head; data != NULL; data = data->next()) { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
500 |
if (loader_data == data) { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
501 |
return true; |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
502 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
503 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
504 |
|
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
505 |
return false; |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
506 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
507 |
#endif // PRODUCT |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
508 |
|
52014
1aa9beac610e
8210754: print_location is not reliable enough (printing register info)
mdoerr
parents:
51959
diff
changeset
|
509 |
bool ClassLoaderDataGraph::is_valid(ClassLoaderData* loader_data) { |
1aa9beac610e
8210754: print_location is not reliable enough (printing register info)
mdoerr
parents:
51959
diff
changeset
|
510 |
DEBUG_ONLY( if (!VMError::is_error_reported()) { assert_locked_or_safepoint(ClassLoaderDataGraph_lock); } ) |
1aa9beac610e
8210754: print_location is not reliable enough (printing register info)
mdoerr
parents:
51959
diff
changeset
|
511 |
if (loader_data != NULL) { |
1aa9beac610e
8210754: print_location is not reliable enough (printing register info)
mdoerr
parents:
51959
diff
changeset
|
512 |
if (loader_data == ClassLoaderData::the_null_class_loader_data()) { |
1aa9beac610e
8210754: print_location is not reliable enough (printing register info)
mdoerr
parents:
51959
diff
changeset
|
513 |
return true; |
1aa9beac610e
8210754: print_location is not reliable enough (printing register info)
mdoerr
parents:
51959
diff
changeset
|
514 |
} |
1aa9beac610e
8210754: print_location is not reliable enough (printing register info)
mdoerr
parents:
51959
diff
changeset
|
515 |
for (ClassLoaderData* data = _head; data != NULL; data = data->next()) { |
1aa9beac610e
8210754: print_location is not reliable enough (printing register info)
mdoerr
parents:
51959
diff
changeset
|
516 |
if (loader_data == data) { |
1aa9beac610e
8210754: print_location is not reliable enough (printing register info)
mdoerr
parents:
51959
diff
changeset
|
517 |
return true; |
1aa9beac610e
8210754: print_location is not reliable enough (printing register info)
mdoerr
parents:
51959
diff
changeset
|
518 |
} |
1aa9beac610e
8210754: print_location is not reliable enough (printing register info)
mdoerr
parents:
51959
diff
changeset
|
519 |
} |
1aa9beac610e
8210754: print_location is not reliable enough (printing register info)
mdoerr
parents:
51959
diff
changeset
|
520 |
} |
1aa9beac610e
8210754: print_location is not reliable enough (printing register info)
mdoerr
parents:
51959
diff
changeset
|
521 |
return false; |
1aa9beac610e
8210754: print_location is not reliable enough (printing register info)
mdoerr
parents:
51959
diff
changeset
|
522 |
} |
1aa9beac610e
8210754: print_location is not reliable enough (printing register info)
mdoerr
parents:
51959
diff
changeset
|
523 |
|
51959
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
524 |
// Move class loader data from main list to the unloaded list for unloading |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
525 |
// and deallocation later. |
52498
c3066f7465fa
8213307: G1 should clean up RMT with ClassUnloadingWithConcurrentMark
tschatzl
parents:
52344
diff
changeset
|
526 |
bool ClassLoaderDataGraph::do_unloading() { |
51959
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
527 |
assert_locked_or_safepoint(ClassLoaderDataGraph_lock); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
528 |
|
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
529 |
// Indicate whether safepoint cleanup is needed. |
52498
c3066f7465fa
8213307: G1 should clean up RMT with ClassUnloadingWithConcurrentMark
tschatzl
parents:
52344
diff
changeset
|
530 |
_safepoint_cleanup_needed = true; |
51959
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
531 |
|
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
532 |
ClassLoaderData* data = _head; |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
533 |
ClassLoaderData* prev = NULL; |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
534 |
bool seen_dead_loader = false; |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
535 |
uint loaders_processed = 0; |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
536 |
uint loaders_removed = 0; |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
537 |
|
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
538 |
// Save previous _unloading pointer for CMS which may add to unloading list before |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
539 |
// purging and we don't want to rewalk the previously unloaded class loader data. |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
540 |
_saved_unloading = _unloading; |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
541 |
|
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
542 |
data = _head; |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
543 |
while (data != NULL) { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
544 |
if (data->is_alive()) { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
545 |
prev = data; |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
546 |
data = data->next(); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
547 |
loaders_processed++; |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
548 |
continue; |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
549 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
550 |
seen_dead_loader = true; |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
551 |
loaders_removed++; |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
552 |
ClassLoaderData* dead = data; |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
553 |
dead->unload(); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
554 |
data = data->next(); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
555 |
// Remove from loader list. |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
556 |
// This class loader data will no longer be found |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
557 |
// in the ClassLoaderDataGraph. |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
558 |
if (prev != NULL) { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
559 |
prev->set_next(data); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
560 |
} else { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
561 |
assert(dead == _head, "sanity check"); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
562 |
_head = data; |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
563 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
564 |
dead->set_next(_unloading); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
565 |
_unloading = dead; |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
566 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
567 |
|
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
568 |
log_debug(class, loader, data)("do_unloading: loaders processed %u, loaders removed %u", loaders_processed, loaders_removed); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
569 |
|
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
570 |
return seen_dead_loader; |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
571 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
572 |
|
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
573 |
// There's at least one dead class loader. Purge refererences of healthy module |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
574 |
// reads lists and package export lists to modules belonging to dead loaders. |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
575 |
void ClassLoaderDataGraph::clean_module_and_package_info() { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
576 |
assert_locked_or_safepoint(ClassLoaderDataGraph_lock); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
577 |
|
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
578 |
ClassLoaderData* data = _head; |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
579 |
while (data != NULL) { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
580 |
// Walk a ModuleEntry's reads, and a PackageEntry's exports |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
581 |
// lists to determine if there are modules on those lists that are now |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
582 |
// dead and should be removed. A module's life cycle is equivalent |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
583 |
// to its defining class loader's life cycle. Since a module is |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
584 |
// considered dead if its class loader is dead, these walks must |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
585 |
// occur after each class loader's aliveness is determined. |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
586 |
if (data->packages() != NULL) { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
587 |
data->packages()->purge_all_package_exports(); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
588 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
589 |
if (data->modules_defined()) { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
590 |
data->modules()->purge_all_module_reads(); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
591 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
592 |
data = data->next(); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
593 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
594 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
595 |
|
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
596 |
void ClassLoaderDataGraph::purge() { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
597 |
ClassLoaderData* list = _unloading; |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
598 |
_unloading = NULL; |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
599 |
ClassLoaderData* next = list; |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
600 |
bool classes_unloaded = false; |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
601 |
while (next != NULL) { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
602 |
ClassLoaderData* purge_me = next; |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
603 |
next = purge_me->next(); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
604 |
delete purge_me; |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
605 |
classes_unloaded = true; |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
606 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
607 |
if (classes_unloaded) { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
608 |
Metaspace::purge(); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
609 |
set_metaspace_oom(false); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
610 |
} |
52781
436097b038a1
8213565: Crash in DependencyContext::remove_dependent_nmethod
eosterlund
parents:
52587
diff
changeset
|
611 |
DependencyContext::purge_dependency_contexts(); |
51959
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
612 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
613 |
|
54961
30c8a21ce002
8224119: Safepoint cleanup logging logs times for things it doesn't do
coleenp
parents:
54807
diff
changeset
|
614 |
int ClassLoaderDataGraph::resize_dictionaries() { |
51959
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
615 |
assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint!"); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
616 |
int resized = 0; |
54961
30c8a21ce002
8224119: Safepoint cleanup logging logs times for things it doesn't do
coleenp
parents:
54807
diff
changeset
|
617 |
assert (Dictionary::does_any_dictionary_needs_resizing(), "some dictionary should need resizing"); |
30c8a21ce002
8224119: Safepoint cleanup logging logs times for things it doesn't do
coleenp
parents:
54807
diff
changeset
|
618 |
FOR_ALL_DICTIONARY(cld) { |
30c8a21ce002
8224119: Safepoint cleanup logging logs times for things it doesn't do
coleenp
parents:
54807
diff
changeset
|
619 |
if (cld->dictionary()->resize_if_needed()) { |
30c8a21ce002
8224119: Safepoint cleanup logging logs times for things it doesn't do
coleenp
parents:
54807
diff
changeset
|
620 |
resized++; |
51959
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
621 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
622 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
623 |
return resized; |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
624 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
625 |
|
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
626 |
ClassLoaderDataGraphKlassIteratorAtomic::ClassLoaderDataGraphKlassIteratorAtomic() |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
627 |
: _next_klass(NULL) { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
628 |
assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint!"); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
629 |
ClassLoaderData* cld = ClassLoaderDataGraph::_head; |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
630 |
Klass* klass = NULL; |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
631 |
|
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
632 |
// Find the first klass in the CLDG. |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
633 |
while (cld != NULL) { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
634 |
assert_locked_or_safepoint(cld->metaspace_lock()); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
635 |
klass = cld->_klasses; |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
636 |
if (klass != NULL) { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
637 |
_next_klass = klass; |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
638 |
return; |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
639 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
640 |
cld = cld->next(); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
641 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
642 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
643 |
|
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
644 |
Klass* ClassLoaderDataGraphKlassIteratorAtomic::next_klass_in_cldg(Klass* klass) { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
645 |
Klass* next = klass->next_link(); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
646 |
if (next != NULL) { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
647 |
return next; |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
648 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
649 |
|
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
650 |
// No more klasses in the current CLD. Time to find a new CLD. |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
651 |
ClassLoaderData* cld = klass->class_loader_data(); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
652 |
assert_locked_or_safepoint(cld->metaspace_lock()); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
653 |
while (next == NULL) { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
654 |
cld = cld->next(); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
655 |
if (cld == NULL) { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
656 |
break; |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
657 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
658 |
next = cld->_klasses; |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
659 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
660 |
|
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
661 |
return next; |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
662 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
663 |
|
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
664 |
Klass* ClassLoaderDataGraphKlassIteratorAtomic::next_klass() { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
665 |
Klass* head = _next_klass; |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
666 |
|
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
667 |
while (head != NULL) { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
668 |
Klass* next = next_klass_in_cldg(head); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
669 |
|
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
670 |
Klass* old_head = Atomic::cmpxchg(next, &_next_klass, head); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
671 |
|
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
672 |
if (old_head == head) { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
673 |
return head; // Won the CAS. |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
674 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
675 |
|
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
676 |
head = old_head; |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
677 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
678 |
|
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
679 |
// Nothing more for the iterator to hand out. |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
680 |
assert(head == NULL, "head is " PTR_FORMAT ", expected not null:", p2i(head)); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
681 |
return NULL; |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
682 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
683 |
|
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
684 |
ClassLoaderDataGraphMetaspaceIterator::ClassLoaderDataGraphMetaspaceIterator() { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
685 |
assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint!"); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
686 |
_data = ClassLoaderDataGraph::_head; |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
687 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
688 |
|
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
689 |
ClassLoaderDataGraphMetaspaceIterator::~ClassLoaderDataGraphMetaspaceIterator() {} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
690 |
|
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
691 |
ClassLoaderMetaspace* ClassLoaderDataGraphMetaspaceIterator::get_next() { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
692 |
assert(_data != NULL, "Should not be NULL in call to the iterator"); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
693 |
ClassLoaderMetaspace* result = _data->metaspace_or_null(); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
694 |
_data = _data->next(); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
695 |
// This result might be NULL for class loaders without metaspace |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
696 |
// yet. It would be nice to return only non-null results but |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
697 |
// there is no guarantee that there will be a non-null result |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
698 |
// down the list so the caller is going to have to check. |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
699 |
return result; |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
700 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
701 |
|
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
702 |
#ifndef PRODUCT |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
703 |
// callable from debugger |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
704 |
extern "C" int print_loader_data_graph() { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
705 |
ResourceMark rm; |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
706 |
ClassLoaderDataGraph::print_on(tty); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
707 |
return 0; |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
708 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
709 |
|
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
710 |
void ClassLoaderDataGraph::verify() { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
711 |
ClassLoaderDataGraphIterator iter; |
52344
55711b181dfc
8213107: Make ClassLoaderDataGraph iterator skip unloaded CLDs
coleenp
parents:
52141
diff
changeset
|
712 |
while (ClassLoaderData* cld = iter.get_next()) { |
51959
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
713 |
cld->verify(); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
714 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
715 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
716 |
|
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
717 |
void ClassLoaderDataGraph::print_on(outputStream * const out) { |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
718 |
ClassLoaderDataGraphIterator iter; |
52344
55711b181dfc
8213107: Make ClassLoaderDataGraph iterator skip unloaded CLDs
coleenp
parents:
52141
diff
changeset
|
719 |
while (ClassLoaderData* cld = iter.get_next()) { |
51959
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
720 |
cld->print_on(out); |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
721 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
722 |
} |
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
diff
changeset
|
723 |
#endif // PRODUCT |
54807 | 724 |
|
725 |
void ClassLoaderDataGraph::print() { print_on(tty); } |