author | lfoltan |
Mon, 21 Oct 2019 13:13:16 -0400 | |
changeset 58722 | cba8afa5cfed |
parent 58375 | a1eba2e37671 |
child 58494 | 54c1ba464b78 |
child 58679 | 9c3209ff7550 |
child 59247 | 56bf71d64d51 |
permissions | -rw-r--r-- |
46729 | 1 |
/* |
54343
6a1406c718ec
8221643: Tighten up assert(_keep_alive >= 0) in CLD::inc_keep_alive
zgu
parents:
52852
diff
changeset
|
2 |
* Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved. |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4 |
* |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
8 |
* |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
13 |
* accompanied this code). |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
14 |
* |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
18 |
* |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
21 |
* questions. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
22 |
* |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
23 |
*/ |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
24 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
25 |
// A ClassLoaderData identifies the full set of class types that a class |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
26 |
// loader's name resolution strategy produces for a given configuration of the |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
27 |
// class loader. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
28 |
// Class types in the ClassLoaderData may be defined by from class file binaries |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
29 |
// provided by the class loader, or from other class loader it interacts with |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
30 |
// according to its name resolution strategy. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
31 |
// |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
32 |
// Class loaders that implement a deterministic name resolution strategy |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
33 |
// (including with respect to their delegation behavior), such as the boot, the |
36508 | 34 |
// platform, and the system loaders of the JDK's built-in class loader |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
35 |
// hierarchy, always produce the same linkset for a given configuration. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
36 |
// |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
37 |
// ClassLoaderData carries information related to a linkset (e.g., |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
38 |
// metaspace holding its klass definitions). |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
39 |
// The System Dictionary and related data structures (e.g., placeholder table, |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
40 |
// loader constraints table) as well as the runtime representation of classes |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
41 |
// only reference ClassLoaderData. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
42 |
// |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
43 |
// Instances of java.lang.ClassLoader holds a pointer to a ClassLoaderData that |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
44 |
// that represent the loader's "linking domain" in the JVM. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
45 |
// |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
46 |
// The bootstrap loader (represented by NULL) also has a ClassLoaderData, |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
47 |
// the singleton class the_null_class_loader_data(). |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
48 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
49 |
#include "precompiled.hpp" |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
50 |
#include "classfile/classLoaderData.inline.hpp" |
51959
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
51887
diff
changeset
|
51 |
#include "classfile/classLoaderDataGraph.inline.hpp" |
46729 | 52 |
#include "classfile/dictionary.hpp" |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
53 |
#include "classfile/javaClasses.hpp" |
36508 | 54 |
#include "classfile/moduleEntry.hpp" |
55 |
#include "classfile/packageEntry.hpp" |
|
49824
e242740a92b8
8201556: Disallow reading oops in ClassLoaderData if unloading
coleenp
parents:
49818
diff
changeset
|
56 |
#include "classfile/symbolTable.hpp" |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
57 |
#include "classfile/systemDictionary.hpp" |
35917
463d67f86eaa
8079408: Reimplement TraceClassLoading, TraceClassUnloading, and TraceClassLoaderData with Unified Logging.
mockner
parents:
35492
diff
changeset
|
58 |
#include "logging/log.hpp" |
46701
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46464
diff
changeset
|
59 |
#include "logging/logStream.hpp" |
49360 | 60 |
#include "memory/allocation.inline.hpp" |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
61 |
#include "memory/metadataFactory.hpp" |
37248 | 62 |
#include "memory/resourceArea.hpp" |
48613
d8bdf14c4f1e
8191888: Refactor ClassLoaderData::remove_handle to use the Access API
eosterlund
parents:
48405
diff
changeset
|
63 |
#include "oops/access.inline.hpp" |
29081
c61eb4914428
8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
28365
diff
changeset
|
64 |
#include "oops/oop.inline.hpp" |
49816 | 65 |
#include "oops/oopHandle.inline.hpp" |
49738
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
49658
diff
changeset
|
66 |
#include "oops/weakHandle.inline.hpp" |
40655
9f644073d3a0
8157907: Incorrect inclusion of atomic.hpp instead of atomic.inline.hpp
dholmes
parents:
40358
diff
changeset
|
67 |
#include "runtime/atomic.hpp" |
49393 | 68 |
#include "runtime/handles.inline.hpp" |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
69 |
#include "runtime/mutex.hpp" |
38937
2bf3c37c4841
8154750: Add missing OrderAccess operations to ClassLoaderData lock-free data structures
dholmes
parents:
38635
diff
changeset
|
70 |
#include "runtime/orderAccess.hpp" |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
71 |
#include "runtime/safepoint.hpp" |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
72 |
#include "utilities/growableArray.hpp" |
21767
41eaa9a17059
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
21183
diff
changeset
|
73 |
#include "utilities/macros.hpp" |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
74 |
#include "utilities/ostream.hpp" |
18025 | 75 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
76 |
ClassLoaderData * ClassLoaderData::_the_null_class_loader_data = NULL; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
77 |
|
49348
fde3feaaa4ed
8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents:
49041
diff
changeset
|
78 |
void ClassLoaderData::init_null_class_loader_data() { |
fde3feaaa4ed
8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents:
49041
diff
changeset
|
79 |
assert(_the_null_class_loader_data == NULL, "cannot initialize twice"); |
fde3feaaa4ed
8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents:
49041
diff
changeset
|
80 |
assert(ClassLoaderDataGraph::_head == NULL, "cannot initialize twice"); |
fde3feaaa4ed
8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents:
49041
diff
changeset
|
81 |
|
fde3feaaa4ed
8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents:
49041
diff
changeset
|
82 |
_the_null_class_loader_data = new ClassLoaderData(Handle(), false); |
fde3feaaa4ed
8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents:
49041
diff
changeset
|
83 |
ClassLoaderDataGraph::_head = _the_null_class_loader_data; |
fde3feaaa4ed
8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents:
49041
diff
changeset
|
84 |
assert(_the_null_class_loader_data->is_the_null_class_loader_data(), "Must be"); |
fde3feaaa4ed
8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents:
49041
diff
changeset
|
85 |
|
51338
aa3bfacc912c
8208677: Move inner metaspace cleaning out of class unloading
coleenp
parents:
51334
diff
changeset
|
86 |
LogTarget(Trace, class, loader, data) lt; |
49348
fde3feaaa4ed
8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents:
49041
diff
changeset
|
87 |
if (lt.is_enabled()) { |
fde3feaaa4ed
8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents:
49041
diff
changeset
|
88 |
ResourceMark rm; |
fde3feaaa4ed
8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents:
49041
diff
changeset
|
89 |
LogStream ls(lt); |
fde3feaaa4ed
8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents:
49041
diff
changeset
|
90 |
ls.print("create "); |
fde3feaaa4ed
8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents:
49041
diff
changeset
|
91 |
_the_null_class_loader_data->print_value_on(&ls); |
fde3feaaa4ed
8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents:
49041
diff
changeset
|
92 |
ls.cr(); |
fde3feaaa4ed
8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents:
49041
diff
changeset
|
93 |
} |
fde3feaaa4ed
8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents:
49041
diff
changeset
|
94 |
} |
fde3feaaa4ed
8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents:
49041
diff
changeset
|
95 |
|
50634
c349d409262a
8202605: Standardize on ClassLoaderData::loader_name() throughout the VM to obtain a class loader's name
lfoltan
parents:
50599
diff
changeset
|
96 |
// Obtain and set the class loader's name within the ClassLoaderData so |
c349d409262a
8202605: Standardize on ClassLoaderData::loader_name() throughout the VM to obtain a class loader's name
lfoltan
parents:
50599
diff
changeset
|
97 |
// it will be available for error messages, logging, JFR, etc. The name |
c349d409262a
8202605: Standardize on ClassLoaderData::loader_name() throughout the VM to obtain a class loader's name
lfoltan
parents:
50599
diff
changeset
|
98 |
// and klass are available after the class_loader oop is no longer alive, |
c349d409262a
8202605: Standardize on ClassLoaderData::loader_name() throughout the VM to obtain a class loader's name
lfoltan
parents:
50599
diff
changeset
|
99 |
// during unloading. |
50759
00c4edaf2017
8205509: assert(_name_and_id != 0LL) failed: encountered a class loader null name and id
lfoltan
parents:
50634
diff
changeset
|
100 |
void ClassLoaderData::initialize_name(Handle class_loader) { |
50634
c349d409262a
8202605: Standardize on ClassLoaderData::loader_name() throughout the VM to obtain a class loader's name
lfoltan
parents:
50599
diff
changeset
|
101 |
Thread* THREAD = Thread::current(); |
c349d409262a
8202605: Standardize on ClassLoaderData::loader_name() throughout the VM to obtain a class loader's name
lfoltan
parents:
50599
diff
changeset
|
102 |
ResourceMark rm(THREAD); |
49824
e242740a92b8
8201556: Disallow reading oops in ClassLoaderData if unloading
coleenp
parents:
49818
diff
changeset
|
103 |
|
50634
c349d409262a
8202605: Standardize on ClassLoaderData::loader_name() throughout the VM to obtain a class loader's name
lfoltan
parents:
50599
diff
changeset
|
104 |
// Obtain the class loader's name. If the class loader's name was not |
c349d409262a
8202605: Standardize on ClassLoaderData::loader_name() throughout the VM to obtain a class loader's name
lfoltan
parents:
50599
diff
changeset
|
105 |
// explicitly set during construction, the CLD's _name field will be null. |
c349d409262a
8202605: Standardize on ClassLoaderData::loader_name() throughout the VM to obtain a class loader's name
lfoltan
parents:
50599
diff
changeset
|
106 |
oop cl_name = java_lang_ClassLoader::name(class_loader()); |
c349d409262a
8202605: Standardize on ClassLoaderData::loader_name() throughout the VM to obtain a class loader's name
lfoltan
parents:
50599
diff
changeset
|
107 |
if (cl_name != NULL) { |
c349d409262a
8202605: Standardize on ClassLoaderData::loader_name() throughout the VM to obtain a class loader's name
lfoltan
parents:
50599
diff
changeset
|
108 |
const char* cl_instance_name = java_lang_String::as_utf8_string(cl_name); |
c349d409262a
8202605: Standardize on ClassLoaderData::loader_name() throughout the VM to obtain a class loader's name
lfoltan
parents:
50599
diff
changeset
|
109 |
|
c349d409262a
8202605: Standardize on ClassLoaderData::loader_name() throughout the VM to obtain a class loader's name
lfoltan
parents:
50599
diff
changeset
|
110 |
if (cl_instance_name != NULL && cl_instance_name[0] != '\0') { |
54847
59ea39bb2809
8223657: Remove unused THREAD argument from SymbolTable functions
coleenp
parents:
54807
diff
changeset
|
111 |
_name = SymbolTable::new_symbol(cl_instance_name); |
49824
e242740a92b8
8201556: Disallow reading oops in ClassLoaderData if unloading
coleenp
parents:
49818
diff
changeset
|
112 |
} |
e242740a92b8
8201556: Disallow reading oops in ClassLoaderData if unloading
coleenp
parents:
49818
diff
changeset
|
113 |
} |
50634
c349d409262a
8202605: Standardize on ClassLoaderData::loader_name() throughout the VM to obtain a class loader's name
lfoltan
parents:
50599
diff
changeset
|
114 |
|
c349d409262a
8202605: Standardize on ClassLoaderData::loader_name() throughout the VM to obtain a class loader's name
lfoltan
parents:
50599
diff
changeset
|
115 |
// Obtain the class loader's name and identity hash. If the class loader's |
c349d409262a
8202605: Standardize on ClassLoaderData::loader_name() throughout the VM to obtain a class loader's name
lfoltan
parents:
50599
diff
changeset
|
116 |
// name was not explicitly set during construction, the class loader's name and id |
c349d409262a
8202605: Standardize on ClassLoaderData::loader_name() throughout the VM to obtain a class loader's name
lfoltan
parents:
50599
diff
changeset
|
117 |
// will be set to the qualified class name of the class loader along with its |
c349d409262a
8202605: Standardize on ClassLoaderData::loader_name() throughout the VM to obtain a class loader's name
lfoltan
parents:
50599
diff
changeset
|
118 |
// identity hash. |
c349d409262a
8202605: Standardize on ClassLoaderData::loader_name() throughout the VM to obtain a class loader's name
lfoltan
parents:
50599
diff
changeset
|
119 |
// If for some reason the ClassLoader's constructor has not been run, instead of |
c349d409262a
8202605: Standardize on ClassLoaderData::loader_name() throughout the VM to obtain a class loader's name
lfoltan
parents:
50599
diff
changeset
|
120 |
// leaving the _name_and_id field null, fall back to the external qualified class |
c349d409262a
8202605: Standardize on ClassLoaderData::loader_name() throughout the VM to obtain a class loader's name
lfoltan
parents:
50599
diff
changeset
|
121 |
// name. Thus CLD's _name_and_id field should never have a null value. |
c349d409262a
8202605: Standardize on ClassLoaderData::loader_name() throughout the VM to obtain a class loader's name
lfoltan
parents:
50599
diff
changeset
|
122 |
oop cl_name_and_id = java_lang_ClassLoader::nameAndId(class_loader()); |
c349d409262a
8202605: Standardize on ClassLoaderData::loader_name() throughout the VM to obtain a class loader's name
lfoltan
parents:
50599
diff
changeset
|
123 |
const char* cl_instance_name_and_id = |
c349d409262a
8202605: Standardize on ClassLoaderData::loader_name() throughout the VM to obtain a class loader's name
lfoltan
parents:
50599
diff
changeset
|
124 |
(cl_name_and_id == NULL) ? _class_loader_klass->external_name() : |
c349d409262a
8202605: Standardize on ClassLoaderData::loader_name() throughout the VM to obtain a class loader's name
lfoltan
parents:
50599
diff
changeset
|
125 |
java_lang_String::as_utf8_string(cl_name_and_id); |
c349d409262a
8202605: Standardize on ClassLoaderData::loader_name() throughout the VM to obtain a class loader's name
lfoltan
parents:
50599
diff
changeset
|
126 |
assert(cl_instance_name_and_id != NULL && cl_instance_name_and_id[0] != '\0', "class loader has no name and id"); |
54847
59ea39bb2809
8223657: Remove unused THREAD argument from SymbolTable functions
coleenp
parents:
54807
diff
changeset
|
127 |
_name_and_id = SymbolTable::new_symbol(cl_instance_name_and_id); |
49824
e242740a92b8
8201556: Disallow reading oops in ClassLoaderData if unloading
coleenp
parents:
49818
diff
changeset
|
128 |
} |
e242740a92b8
8201556: Disallow reading oops in ClassLoaderData if unloading
coleenp
parents:
49818
diff
changeset
|
129 |
|
51444
3e5d28e6de32
8209301: JVM rename is_anonymous, host_klass to unsafe specific terminology ahead of Unsafe.defineAnonymousClass deprecation
lfoltan
parents:
51415
diff
changeset
|
130 |
ClassLoaderData::ClassLoaderData(Handle h_class_loader, bool is_unsafe_anonymous) : |
51334
cc2c79d22508
8208671: Runtime, JFR, Serviceability changes to allow enabling -Wreorder
tschatzl
parents:
50803
diff
changeset
|
131 |
_metaspace(NULL), |
58375
a1eba2e37671
8231472: Clean up Monitor::_safepoint_check usage to Mutex::_safepoint_check
coleenp
parents:
58177
diff
changeset
|
132 |
_metaspace_lock(new Mutex(Mutex::leaf+1, "Metaspace allocation lock", true, |
a1eba2e37671
8231472: Clean up Monitor::_safepoint_check usage to Mutex::_safepoint_check
coleenp
parents:
58177
diff
changeset
|
133 |
Mutex::_safepoint_check_never)), |
51444
3e5d28e6de32
8209301: JVM rename is_anonymous, host_klass to unsafe specific terminology ahead of Unsafe.defineAnonymousClass deprecation
lfoltan
parents:
51415
diff
changeset
|
134 |
_unloading(false), _is_unsafe_anonymous(is_unsafe_anonymous), |
51334
cc2c79d22508
8208671: Runtime, JFR, Serviceability changes to allow enabling -Wreorder
tschatzl
parents:
50803
diff
changeset
|
135 |
_modified_oops(true), _accumulated_modified_oops(false), |
51444
3e5d28e6de32
8209301: JVM rename is_anonymous, host_klass to unsafe specific terminology ahead of Unsafe.defineAnonymousClass deprecation
lfoltan
parents:
51415
diff
changeset
|
136 |
// An unsafe anonymous class loader data doesn't have anything to keep |
3e5d28e6de32
8209301: JVM rename is_anonymous, host_klass to unsafe specific terminology ahead of Unsafe.defineAnonymousClass deprecation
lfoltan
parents:
51415
diff
changeset
|
137 |
// it from being unloaded during parsing of the unsafe anonymous class. |
22900 | 138 |
// The null-class-loader should always be kept alive. |
51444
3e5d28e6de32
8209301: JVM rename is_anonymous, host_klass to unsafe specific terminology ahead of Unsafe.defineAnonymousClass deprecation
lfoltan
parents:
51415
diff
changeset
|
139 |
_keep_alive((is_unsafe_anonymous || h_class_loader.is_null()) ? 1 : 0), |
52141
de6dc206a92b
8210330: Make CLD claiming allow multiple claim bits
eosterlund
parents:
51962
diff
changeset
|
140 |
_claim(0), |
51334
cc2c79d22508
8208671: Runtime, JFR, Serviceability changes to allow enabling -Wreorder
tschatzl
parents:
50803
diff
changeset
|
141 |
_handles(), |
cc2c79d22508
8208671: Runtime, JFR, Serviceability changes to allow enabling -Wreorder
tschatzl
parents:
50803
diff
changeset
|
142 |
_klasses(NULL), _packages(NULL), _modules(NULL), _unnamed_module(NULL), _dictionary(NULL), |
cc2c79d22508
8208671: Runtime, JFR, Serviceability changes to allow enabling -Wreorder
tschatzl
parents:
50803
diff
changeset
|
143 |
_jmethod_ids(NULL), |
cc2c79d22508
8208671: Runtime, JFR, Serviceability changes to allow enabling -Wreorder
tschatzl
parents:
50803
diff
changeset
|
144 |
_deallocate_list(NULL), |
49348
fde3feaaa4ed
8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents:
49041
diff
changeset
|
145 |
_next(NULL), |
51334
cc2c79d22508
8208671: Runtime, JFR, Serviceability changes to allow enabling -Wreorder
tschatzl
parents:
50803
diff
changeset
|
146 |
_class_loader_klass(NULL), _name(NULL), _name_and_id(NULL) { |
46387 | 147 |
|
49824
e242740a92b8
8201556: Disallow reading oops in ClassLoaderData if unloading
coleenp
parents:
49818
diff
changeset
|
148 |
if (!h_class_loader.is_null()) { |
e242740a92b8
8201556: Disallow reading oops in ClassLoaderData if unloading
coleenp
parents:
49818
diff
changeset
|
149 |
_class_loader = _handles.add(h_class_loader()); |
50759
00c4edaf2017
8205509: assert(_name_and_id != 0LL) failed: encountered a class loader null name and id
lfoltan
parents:
50634
diff
changeset
|
150 |
_class_loader_klass = h_class_loader->klass(); |
51698
74dde8b66b7f
8210422: runtime/modules/ModuleStress/ExportModuleStressTest.java - assertion failed: address not aligned: 0x00000008baadbabe
coleenp
parents:
51682
diff
changeset
|
151 |
initialize_name(h_class_loader); |
49824
e242740a92b8
8201556: Disallow reading oops in ClassLoaderData if unloading
coleenp
parents:
49818
diff
changeset
|
152 |
} |
e242740a92b8
8201556: Disallow reading oops in ClassLoaderData if unloading
coleenp
parents:
49818
diff
changeset
|
153 |
|
51444
3e5d28e6de32
8209301: JVM rename is_anonymous, host_klass to unsafe specific terminology ahead of Unsafe.defineAnonymousClass deprecation
lfoltan
parents:
51415
diff
changeset
|
154 |
if (!is_unsafe_anonymous) { |
3e5d28e6de32
8209301: JVM rename is_anonymous, host_klass to unsafe specific terminology ahead of Unsafe.defineAnonymousClass deprecation
lfoltan
parents:
51415
diff
changeset
|
155 |
// The holder is initialized later for unsafe anonymous classes, and before calling anything |
49738
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
49658
diff
changeset
|
156 |
// that call class_loader(). |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
49658
diff
changeset
|
157 |
initialize_holder(h_class_loader); |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
49658
diff
changeset
|
158 |
|
51444
3e5d28e6de32
8209301: JVM rename is_anonymous, host_klass to unsafe specific terminology ahead of Unsafe.defineAnonymousClass deprecation
lfoltan
parents:
51415
diff
changeset
|
159 |
// A ClassLoaderData created solely for an unsafe anonymous class should never have a |
49738
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
49658
diff
changeset
|
160 |
// ModuleEntryTable or PackageEntryTable created for it. The defining package |
51444
3e5d28e6de32
8209301: JVM rename is_anonymous, host_klass to unsafe specific terminology ahead of Unsafe.defineAnonymousClass deprecation
lfoltan
parents:
51415
diff
changeset
|
161 |
// and module for an unsafe anonymous class will be found in its host class. |
46420
227f72691ac1
8179235: PackageEntryTables should be created eagerly
hseigel
parents:
46387
diff
changeset
|
162 |
_packages = new PackageEntryTable(PackageEntryTable::_packagetable_entry_size); |
46387 | 163 |
if (h_class_loader.is_null()) { |
164 |
// Create unnamed module for boot loader |
|
165 |
_unnamed_module = ModuleEntry::create_boot_unnamed_module(this); |
|
166 |
} else { |
|
167 |
// Create unnamed module for all other loaders |
|
168 |
_unnamed_module = ModuleEntry::create_unnamed_module(this); |
|
169 |
} |
|
46729 | 170 |
_dictionary = create_dictionary(); |
171 |
} |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
172 |
|
49348
fde3feaaa4ed
8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents:
49041
diff
changeset
|
173 |
NOT_PRODUCT(_dependency_count = 0); // number of class loader dependencies |
16684
2af47517ffbd
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
16617
diff
changeset
|
174 |
|
50113 | 175 |
JFR_ONLY(INIT_ID(this);) |
14588
8ec26d2d9339
8000662: NPG: nashorn ant clean test262 out-of-memory with Java heap
coleenp
parents:
13728
diff
changeset
|
176 |
} |
8ec26d2d9339
8000662: NPG: nashorn ant clean test262 out-of-memory with Java heap
coleenp
parents:
13728
diff
changeset
|
177 |
|
44084
501b6d07e6dd
8168914: Crash in ClassLoaderData/JNIHandleBlock::oops_do during concurrent marking
ehelin
parents:
43410
diff
changeset
|
178 |
ClassLoaderData::ChunkedHandleList::~ChunkedHandleList() { |
501b6d07e6dd
8168914: Crash in ClassLoaderData/JNIHandleBlock::oops_do during concurrent marking
ehelin
parents:
43410
diff
changeset
|
179 |
Chunk* c = _head; |
501b6d07e6dd
8168914: Crash in ClassLoaderData/JNIHandleBlock::oops_do during concurrent marking
ehelin
parents:
43410
diff
changeset
|
180 |
while (c != NULL) { |
501b6d07e6dd
8168914: Crash in ClassLoaderData/JNIHandleBlock::oops_do during concurrent marking
ehelin
parents:
43410
diff
changeset
|
181 |
Chunk* next = c->_next; |
501b6d07e6dd
8168914: Crash in ClassLoaderData/JNIHandleBlock::oops_do during concurrent marking
ehelin
parents:
43410
diff
changeset
|
182 |
delete c; |
501b6d07e6dd
8168914: Crash in ClassLoaderData/JNIHandleBlock::oops_do during concurrent marking
ehelin
parents:
43410
diff
changeset
|
183 |
c = next; |
501b6d07e6dd
8168914: Crash in ClassLoaderData/JNIHandleBlock::oops_do during concurrent marking
ehelin
parents:
43410
diff
changeset
|
184 |
} |
501b6d07e6dd
8168914: Crash in ClassLoaderData/JNIHandleBlock::oops_do during concurrent marking
ehelin
parents:
43410
diff
changeset
|
185 |
} |
501b6d07e6dd
8168914: Crash in ClassLoaderData/JNIHandleBlock::oops_do during concurrent marking
ehelin
parents:
43410
diff
changeset
|
186 |
|
501b6d07e6dd
8168914: Crash in ClassLoaderData/JNIHandleBlock::oops_do during concurrent marking
ehelin
parents:
43410
diff
changeset
|
187 |
oop* ClassLoaderData::ChunkedHandleList::add(oop o) { |
501b6d07e6dd
8168914: Crash in ClassLoaderData/JNIHandleBlock::oops_do during concurrent marking
ehelin
parents:
43410
diff
changeset
|
188 |
if (_head == NULL || _head->_size == Chunk::CAPACITY) { |
501b6d07e6dd
8168914: Crash in ClassLoaderData/JNIHandleBlock::oops_do during concurrent marking
ehelin
parents:
43410
diff
changeset
|
189 |
Chunk* next = new Chunk(_head); |
47634
6a0c42c40cd1
8188220: Remove Atomic::*_ptr() uses and overloads from hotspot
coleenp
parents:
47580
diff
changeset
|
190 |
OrderAccess::release_store(&_head, next); |
44084
501b6d07e6dd
8168914: Crash in ClassLoaderData/JNIHandleBlock::oops_do during concurrent marking
ehelin
parents:
43410
diff
changeset
|
191 |
} |
501b6d07e6dd
8168914: Crash in ClassLoaderData/JNIHandleBlock::oops_do during concurrent marking
ehelin
parents:
43410
diff
changeset
|
192 |
oop* handle = &_head->_data[_head->_size]; |
52852
eb95a38b2964
8214782: Add missing access barriers on CLD handle area
pliden
parents:
52587
diff
changeset
|
193 |
NativeAccess<IS_DEST_UNINITIALIZED>::oop_store(handle, o); |
44084
501b6d07e6dd
8168914: Crash in ClassLoaderData/JNIHandleBlock::oops_do during concurrent marking
ehelin
parents:
43410
diff
changeset
|
194 |
OrderAccess::release_store(&_head->_size, _head->_size + 1); |
501b6d07e6dd
8168914: Crash in ClassLoaderData/JNIHandleBlock::oops_do during concurrent marking
ehelin
parents:
43410
diff
changeset
|
195 |
return handle; |
501b6d07e6dd
8168914: Crash in ClassLoaderData/JNIHandleBlock::oops_do during concurrent marking
ehelin
parents:
43410
diff
changeset
|
196 |
} |
501b6d07e6dd
8168914: Crash in ClassLoaderData/JNIHandleBlock::oops_do during concurrent marking
ehelin
parents:
43410
diff
changeset
|
197 |
|
49348
fde3feaaa4ed
8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents:
49041
diff
changeset
|
198 |
int ClassLoaderData::ChunkedHandleList::count() const { |
fde3feaaa4ed
8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents:
49041
diff
changeset
|
199 |
int count = 0; |
fde3feaaa4ed
8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents:
49041
diff
changeset
|
200 |
Chunk* chunk = _head; |
fde3feaaa4ed
8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents:
49041
diff
changeset
|
201 |
while (chunk != NULL) { |
fde3feaaa4ed
8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents:
49041
diff
changeset
|
202 |
count += chunk->_size; |
fde3feaaa4ed
8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents:
49041
diff
changeset
|
203 |
chunk = chunk->_next; |
fde3feaaa4ed
8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents:
49041
diff
changeset
|
204 |
} |
fde3feaaa4ed
8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents:
49041
diff
changeset
|
205 |
return count; |
fde3feaaa4ed
8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents:
49041
diff
changeset
|
206 |
} |
fde3feaaa4ed
8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents:
49041
diff
changeset
|
207 |
|
44084
501b6d07e6dd
8168914: Crash in ClassLoaderData/JNIHandleBlock::oops_do during concurrent marking
ehelin
parents:
43410
diff
changeset
|
208 |
inline void ClassLoaderData::ChunkedHandleList::oops_do_chunk(OopClosure* f, Chunk* c, const juint size) { |
501b6d07e6dd
8168914: Crash in ClassLoaderData/JNIHandleBlock::oops_do during concurrent marking
ehelin
parents:
43410
diff
changeset
|
209 |
for (juint i = 0; i < size; i++) { |
501b6d07e6dd
8168914: Crash in ClassLoaderData/JNIHandleBlock::oops_do during concurrent marking
ehelin
parents:
43410
diff
changeset
|
210 |
if (c->_data[i] != NULL) { |
501b6d07e6dd
8168914: Crash in ClassLoaderData/JNIHandleBlock::oops_do during concurrent marking
ehelin
parents:
43410
diff
changeset
|
211 |
f->do_oop(&c->_data[i]); |
501b6d07e6dd
8168914: Crash in ClassLoaderData/JNIHandleBlock::oops_do during concurrent marking
ehelin
parents:
43410
diff
changeset
|
212 |
} |
501b6d07e6dd
8168914: Crash in ClassLoaderData/JNIHandleBlock::oops_do during concurrent marking
ehelin
parents:
43410
diff
changeset
|
213 |
} |
501b6d07e6dd
8168914: Crash in ClassLoaderData/JNIHandleBlock::oops_do during concurrent marking
ehelin
parents:
43410
diff
changeset
|
214 |
} |
501b6d07e6dd
8168914: Crash in ClassLoaderData/JNIHandleBlock::oops_do during concurrent marking
ehelin
parents:
43410
diff
changeset
|
215 |
|
501b6d07e6dd
8168914: Crash in ClassLoaderData/JNIHandleBlock::oops_do during concurrent marking
ehelin
parents:
43410
diff
changeset
|
216 |
void ClassLoaderData::ChunkedHandleList::oops_do(OopClosure* f) { |
47634
6a0c42c40cd1
8188220: Remove Atomic::*_ptr() uses and overloads from hotspot
coleenp
parents:
47580
diff
changeset
|
217 |
Chunk* head = OrderAccess::load_acquire(&_head); |
44084
501b6d07e6dd
8168914: Crash in ClassLoaderData/JNIHandleBlock::oops_do during concurrent marking
ehelin
parents:
43410
diff
changeset
|
218 |
if (head != NULL) { |
501b6d07e6dd
8168914: Crash in ClassLoaderData/JNIHandleBlock::oops_do during concurrent marking
ehelin
parents:
43410
diff
changeset
|
219 |
// Must be careful when reading size of head |
501b6d07e6dd
8168914: Crash in ClassLoaderData/JNIHandleBlock::oops_do during concurrent marking
ehelin
parents:
43410
diff
changeset
|
220 |
oops_do_chunk(f, head, OrderAccess::load_acquire(&head->_size)); |
501b6d07e6dd
8168914: Crash in ClassLoaderData/JNIHandleBlock::oops_do during concurrent marking
ehelin
parents:
43410
diff
changeset
|
221 |
for (Chunk* c = head->_next; c != NULL; c = c->_next) { |
501b6d07e6dd
8168914: Crash in ClassLoaderData/JNIHandleBlock::oops_do during concurrent marking
ehelin
parents:
43410
diff
changeset
|
222 |
oops_do_chunk(f, c, c->_size); |
501b6d07e6dd
8168914: Crash in ClassLoaderData/JNIHandleBlock::oops_do during concurrent marking
ehelin
parents:
43410
diff
changeset
|
223 |
} |
501b6d07e6dd
8168914: Crash in ClassLoaderData/JNIHandleBlock::oops_do during concurrent marking
ehelin
parents:
43410
diff
changeset
|
224 |
} |
501b6d07e6dd
8168914: Crash in ClassLoaderData/JNIHandleBlock::oops_do during concurrent marking
ehelin
parents:
43410
diff
changeset
|
225 |
} |
501b6d07e6dd
8168914: Crash in ClassLoaderData/JNIHandleBlock::oops_do during concurrent marking
ehelin
parents:
43410
diff
changeset
|
226 |
|
501b6d07e6dd
8168914: Crash in ClassLoaderData/JNIHandleBlock::oops_do during concurrent marking
ehelin
parents:
43410
diff
changeset
|
227 |
class VerifyContainsOopClosure : public OopClosure { |
49348
fde3feaaa4ed
8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents:
49041
diff
changeset
|
228 |
oop _target; |
44084
501b6d07e6dd
8168914: Crash in ClassLoaderData/JNIHandleBlock::oops_do during concurrent marking
ehelin
parents:
43410
diff
changeset
|
229 |
bool _found; |
501b6d07e6dd
8168914: Crash in ClassLoaderData/JNIHandleBlock::oops_do during concurrent marking
ehelin
parents:
43410
diff
changeset
|
230 |
|
501b6d07e6dd
8168914: Crash in ClassLoaderData/JNIHandleBlock::oops_do during concurrent marking
ehelin
parents:
43410
diff
changeset
|
231 |
public: |
49348
fde3feaaa4ed
8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents:
49041
diff
changeset
|
232 |
VerifyContainsOopClosure(oop target) : _target(target), _found(false) {} |
44084
501b6d07e6dd
8168914: Crash in ClassLoaderData/JNIHandleBlock::oops_do during concurrent marking
ehelin
parents:
43410
diff
changeset
|
233 |
|
501b6d07e6dd
8168914: Crash in ClassLoaderData/JNIHandleBlock::oops_do during concurrent marking
ehelin
parents:
43410
diff
changeset
|
234 |
void do_oop(oop* p) { |
58177 | 235 |
if (p != NULL && NativeAccess<AS_NO_KEEPALIVE>::oop_load(p) == _target) { |
44084
501b6d07e6dd
8168914: Crash in ClassLoaderData/JNIHandleBlock::oops_do during concurrent marking
ehelin
parents:
43410
diff
changeset
|
236 |
_found = true; |
501b6d07e6dd
8168914: Crash in ClassLoaderData/JNIHandleBlock::oops_do during concurrent marking
ehelin
parents:
43410
diff
changeset
|
237 |
} |
501b6d07e6dd
8168914: Crash in ClassLoaderData/JNIHandleBlock::oops_do during concurrent marking
ehelin
parents:
43410
diff
changeset
|
238 |
} |
501b6d07e6dd
8168914: Crash in ClassLoaderData/JNIHandleBlock::oops_do during concurrent marking
ehelin
parents:
43410
diff
changeset
|
239 |
|
501b6d07e6dd
8168914: Crash in ClassLoaderData/JNIHandleBlock::oops_do during concurrent marking
ehelin
parents:
43410
diff
changeset
|
240 |
void do_oop(narrowOop* p) { |
501b6d07e6dd
8168914: Crash in ClassLoaderData/JNIHandleBlock::oops_do during concurrent marking
ehelin
parents:
43410
diff
changeset
|
241 |
// The ChunkedHandleList should not contain any narrowOop |
501b6d07e6dd
8168914: Crash in ClassLoaderData/JNIHandleBlock::oops_do during concurrent marking
ehelin
parents:
43410
diff
changeset
|
242 |
ShouldNotReachHere(); |
501b6d07e6dd
8168914: Crash in ClassLoaderData/JNIHandleBlock::oops_do during concurrent marking
ehelin
parents:
43410
diff
changeset
|
243 |
} |
501b6d07e6dd
8168914: Crash in ClassLoaderData/JNIHandleBlock::oops_do during concurrent marking
ehelin
parents:
43410
diff
changeset
|
244 |
|
501b6d07e6dd
8168914: Crash in ClassLoaderData/JNIHandleBlock::oops_do during concurrent marking
ehelin
parents:
43410
diff
changeset
|
245 |
bool found() const { |
501b6d07e6dd
8168914: Crash in ClassLoaderData/JNIHandleBlock::oops_do during concurrent marking
ehelin
parents:
43410
diff
changeset
|
246 |
return _found; |
501b6d07e6dd
8168914: Crash in ClassLoaderData/JNIHandleBlock::oops_do during concurrent marking
ehelin
parents:
43410
diff
changeset
|
247 |
} |
501b6d07e6dd
8168914: Crash in ClassLoaderData/JNIHandleBlock::oops_do during concurrent marking
ehelin
parents:
43410
diff
changeset
|
248 |
}; |
501b6d07e6dd
8168914: Crash in ClassLoaderData/JNIHandleBlock::oops_do during concurrent marking
ehelin
parents:
43410
diff
changeset
|
249 |
|
49348
fde3feaaa4ed
8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents:
49041
diff
changeset
|
250 |
bool ClassLoaderData::ChunkedHandleList::contains(oop p) { |
44084
501b6d07e6dd
8168914: Crash in ClassLoaderData/JNIHandleBlock::oops_do during concurrent marking
ehelin
parents:
43410
diff
changeset
|
251 |
VerifyContainsOopClosure cl(p); |
501b6d07e6dd
8168914: Crash in ClassLoaderData/JNIHandleBlock::oops_do during concurrent marking
ehelin
parents:
43410
diff
changeset
|
252 |
oops_do(&cl); |
501b6d07e6dd
8168914: Crash in ClassLoaderData/JNIHandleBlock::oops_do during concurrent marking
ehelin
parents:
43410
diff
changeset
|
253 |
return cl.found(); |
501b6d07e6dd
8168914: Crash in ClassLoaderData/JNIHandleBlock::oops_do during concurrent marking
ehelin
parents:
43410
diff
changeset
|
254 |
} |
501b6d07e6dd
8168914: Crash in ClassLoaderData/JNIHandleBlock::oops_do during concurrent marking
ehelin
parents:
43410
diff
changeset
|
255 |
|
49403
58fdb6c2a274
8199272: Broken assertion in ClassLoaderData::remove_handle
coleenp
parents:
49401
diff
changeset
|
256 |
#ifndef PRODUCT |
58fdb6c2a274
8199272: Broken assertion in ClassLoaderData::remove_handle
coleenp
parents:
49401
diff
changeset
|
257 |
bool ClassLoaderData::ChunkedHandleList::owner_of(oop* oop_handle) { |
58fdb6c2a274
8199272: Broken assertion in ClassLoaderData::remove_handle
coleenp
parents:
49401
diff
changeset
|
258 |
Chunk* chunk = _head; |
58fdb6c2a274
8199272: Broken assertion in ClassLoaderData::remove_handle
coleenp
parents:
49401
diff
changeset
|
259 |
while (chunk != NULL) { |
58fdb6c2a274
8199272: Broken assertion in ClassLoaderData::remove_handle
coleenp
parents:
49401
diff
changeset
|
260 |
if (&(chunk->_data[0]) <= oop_handle && oop_handle < &(chunk->_data[chunk->_size])) { |
58fdb6c2a274
8199272: Broken assertion in ClassLoaderData::remove_handle
coleenp
parents:
49401
diff
changeset
|
261 |
return true; |
58fdb6c2a274
8199272: Broken assertion in ClassLoaderData::remove_handle
coleenp
parents:
49401
diff
changeset
|
262 |
} |
58fdb6c2a274
8199272: Broken assertion in ClassLoaderData::remove_handle
coleenp
parents:
49401
diff
changeset
|
263 |
chunk = chunk->_next; |
58fdb6c2a274
8199272: Broken assertion in ClassLoaderData::remove_handle
coleenp
parents:
49401
diff
changeset
|
264 |
} |
58fdb6c2a274
8199272: Broken assertion in ClassLoaderData::remove_handle
coleenp
parents:
49401
diff
changeset
|
265 |
return false; |
58fdb6c2a274
8199272: Broken assertion in ClassLoaderData::remove_handle
coleenp
parents:
49401
diff
changeset
|
266 |
} |
58fdb6c2a274
8199272: Broken assertion in ClassLoaderData::remove_handle
coleenp
parents:
49401
diff
changeset
|
267 |
#endif // PRODUCT |
58fdb6c2a274
8199272: Broken assertion in ClassLoaderData::remove_handle
coleenp
parents:
49401
diff
changeset
|
268 |
|
55603
3868dde58ebb
8227175: ZGC: ZHeapIterator visits potentially dead objects
stefank
parents:
54847
diff
changeset
|
269 |
void ClassLoaderData::clear_claim(int claim) { |
3868dde58ebb
8227175: ZGC: ZHeapIterator visits potentially dead objects
stefank
parents:
54847
diff
changeset
|
270 |
for (;;) { |
3868dde58ebb
8227175: ZGC: ZHeapIterator visits potentially dead objects
stefank
parents:
54847
diff
changeset
|
271 |
int old_claim = Atomic::load(&_claim); |
3868dde58ebb
8227175: ZGC: ZHeapIterator visits potentially dead objects
stefank
parents:
54847
diff
changeset
|
272 |
if ((old_claim & claim) == 0) { |
3868dde58ebb
8227175: ZGC: ZHeapIterator visits potentially dead objects
stefank
parents:
54847
diff
changeset
|
273 |
return; |
3868dde58ebb
8227175: ZGC: ZHeapIterator visits potentially dead objects
stefank
parents:
54847
diff
changeset
|
274 |
} |
3868dde58ebb
8227175: ZGC: ZHeapIterator visits potentially dead objects
stefank
parents:
54847
diff
changeset
|
275 |
int new_claim = old_claim & ~claim; |
3868dde58ebb
8227175: ZGC: ZHeapIterator visits potentially dead objects
stefank
parents:
54847
diff
changeset
|
276 |
if (Atomic::cmpxchg(new_claim, &_claim, old_claim) == old_claim) { |
3868dde58ebb
8227175: ZGC: ZHeapIterator visits potentially dead objects
stefank
parents:
54847
diff
changeset
|
277 |
return; |
3868dde58ebb
8227175: ZGC: ZHeapIterator visits potentially dead objects
stefank
parents:
54847
diff
changeset
|
278 |
} |
3868dde58ebb
8227175: ZGC: ZHeapIterator visits potentially dead objects
stefank
parents:
54847
diff
changeset
|
279 |
} |
3868dde58ebb
8227175: ZGC: ZHeapIterator visits potentially dead objects
stefank
parents:
54847
diff
changeset
|
280 |
} |
3868dde58ebb
8227175: ZGC: ZHeapIterator visits potentially dead objects
stefank
parents:
54847
diff
changeset
|
281 |
|
52141
de6dc206a92b
8210330: Make CLD claiming allow multiple claim bits
eosterlund
parents:
51962
diff
changeset
|
282 |
bool ClassLoaderData::try_claim(int claim) { |
de6dc206a92b
8210330: Make CLD claiming allow multiple claim bits
eosterlund
parents:
51962
diff
changeset
|
283 |
for (;;) { |
de6dc206a92b
8210330: Make CLD claiming allow multiple claim bits
eosterlund
parents:
51962
diff
changeset
|
284 |
int old_claim = Atomic::load(&_claim); |
de6dc206a92b
8210330: Make CLD claiming allow multiple claim bits
eosterlund
parents:
51962
diff
changeset
|
285 |
if ((old_claim & claim) == claim) { |
de6dc206a92b
8210330: Make CLD claiming allow multiple claim bits
eosterlund
parents:
51962
diff
changeset
|
286 |
return false; |
de6dc206a92b
8210330: Make CLD claiming allow multiple claim bits
eosterlund
parents:
51962
diff
changeset
|
287 |
} |
de6dc206a92b
8210330: Make CLD claiming allow multiple claim bits
eosterlund
parents:
51962
diff
changeset
|
288 |
int new_claim = old_claim | claim; |
de6dc206a92b
8210330: Make CLD claiming allow multiple claim bits
eosterlund
parents:
51962
diff
changeset
|
289 |
if (Atomic::cmpxchg(new_claim, &_claim, old_claim) == old_claim) { |
de6dc206a92b
8210330: Make CLD claiming allow multiple claim bits
eosterlund
parents:
51962
diff
changeset
|
290 |
return true; |
de6dc206a92b
8210330: Make CLD claiming allow multiple claim bits
eosterlund
parents:
51962
diff
changeset
|
291 |
} |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
292 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
293 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
294 |
|
51444
3e5d28e6de32
8209301: JVM rename is_anonymous, host_klass to unsafe specific terminology ahead of Unsafe.defineAnonymousClass deprecation
lfoltan
parents:
51415
diff
changeset
|
295 |
// Unsafe anonymous classes have their own ClassLoaderData that is marked to keep alive |
38014
8731fa11f766
8152949: Jigsaw crash when Klass in _fixup_module_field_list is unloaded
lfoltan
parents:
37415
diff
changeset
|
296 |
// while the class is being parsed, and if the class appears on the module fixup list. |
51444
3e5d28e6de32
8209301: JVM rename is_anonymous, host_klass to unsafe specific terminology ahead of Unsafe.defineAnonymousClass deprecation
lfoltan
parents:
51415
diff
changeset
|
297 |
// Due to the uniqueness that no other class shares the unsafe anonymous class' name or |
3e5d28e6de32
8209301: JVM rename is_anonymous, host_klass to unsafe specific terminology ahead of Unsafe.defineAnonymousClass deprecation
lfoltan
parents:
51415
diff
changeset
|
298 |
// ClassLoaderData, no other non-GC thread has knowledge of the unsafe anonymous class while |
38014
8731fa11f766
8152949: Jigsaw crash when Klass in _fixup_module_field_list is unloaded
lfoltan
parents:
37415
diff
changeset
|
299 |
// it is being defined, therefore _keep_alive is not volatile or atomic. |
8731fa11f766
8152949: Jigsaw crash when Klass in _fixup_module_field_list is unloaded
lfoltan
parents:
37415
diff
changeset
|
300 |
void ClassLoaderData::inc_keep_alive() { |
51444
3e5d28e6de32
8209301: JVM rename is_anonymous, host_klass to unsafe specific terminology ahead of Unsafe.defineAnonymousClass deprecation
lfoltan
parents:
51415
diff
changeset
|
301 |
if (is_unsafe_anonymous()) { |
54343
6a1406c718ec
8221643: Tighten up assert(_keep_alive >= 0) in CLD::inc_keep_alive
zgu
parents:
52852
diff
changeset
|
302 |
assert(_keep_alive > 0, "Invalid keep alive increment count"); |
40358
48774f26918a
8162553: Crash in class unloading due to null CLD having a zero _keep_alive value
lfoltan
parents:
40339
diff
changeset
|
303 |
_keep_alive++; |
48774f26918a
8162553: Crash in class unloading due to null CLD having a zero _keep_alive value
lfoltan
parents:
40339
diff
changeset
|
304 |
} |
38014
8731fa11f766
8152949: Jigsaw crash when Klass in _fixup_module_field_list is unloaded
lfoltan
parents:
37415
diff
changeset
|
305 |
} |
8731fa11f766
8152949: Jigsaw crash when Klass in _fixup_module_field_list is unloaded
lfoltan
parents:
37415
diff
changeset
|
306 |
|
8731fa11f766
8152949: Jigsaw crash when Klass in _fixup_module_field_list is unloaded
lfoltan
parents:
37415
diff
changeset
|
307 |
void ClassLoaderData::dec_keep_alive() { |
51444
3e5d28e6de32
8209301: JVM rename is_anonymous, host_klass to unsafe specific terminology ahead of Unsafe.defineAnonymousClass deprecation
lfoltan
parents:
51415
diff
changeset
|
308 |
if (is_unsafe_anonymous()) { |
40358
48774f26918a
8162553: Crash in class unloading due to null CLD having a zero _keep_alive value
lfoltan
parents:
40339
diff
changeset
|
309 |
assert(_keep_alive > 0, "Invalid keep alive decrement count"); |
48774f26918a
8162553: Crash in class unloading due to null CLD having a zero _keep_alive value
lfoltan
parents:
40339
diff
changeset
|
310 |
_keep_alive--; |
48774f26918a
8162553: Crash in class unloading due to null CLD having a zero _keep_alive value
lfoltan
parents:
40339
diff
changeset
|
311 |
} |
38014
8731fa11f766
8152949: Jigsaw crash when Klass in _fixup_module_field_list is unloaded
lfoltan
parents:
37415
diff
changeset
|
312 |
} |
8731fa11f766
8152949: Jigsaw crash when Klass in _fixup_module_field_list is unloaded
lfoltan
parents:
37415
diff
changeset
|
313 |
|
52141
de6dc206a92b
8210330: Make CLD claiming allow multiple claim bits
eosterlund
parents:
51962
diff
changeset
|
314 |
void ClassLoaderData::oops_do(OopClosure* f, int claim_value, bool clear_mod_oops) { |
de6dc206a92b
8210330: Make CLD claiming allow multiple claim bits
eosterlund
parents:
51962
diff
changeset
|
315 |
if (claim_value != ClassLoaderData::_claim_none && !try_claim(claim_value)) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
316 |
return; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
317 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
318 |
|
47580 | 319 |
// Only clear modified_oops after the ClassLoaderData is claimed. |
320 |
if (clear_mod_oops) { |
|
321 |
clear_modified_oops(); |
|
322 |
} |
|
323 |
||
44084
501b6d07e6dd
8168914: Crash in ClassLoaderData/JNIHandleBlock::oops_do during concurrent marking
ehelin
parents:
43410
diff
changeset
|
324 |
_handles.oops_do(f); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
325 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
326 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
327 |
void ClassLoaderData::classes_do(KlassClosure* klass_closure) { |
47634
6a0c42c40cd1
8188220: Remove Atomic::*_ptr() uses and overloads from hotspot
coleenp
parents:
47580
diff
changeset
|
328 |
// Lock-free access requires load_acquire |
6a0c42c40cd1
8188220: Remove Atomic::*_ptr() uses and overloads from hotspot
coleenp
parents:
47580
diff
changeset
|
329 |
for (Klass* k = OrderAccess::load_acquire(&_klasses); k != NULL; k = k->next_link()) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
330 |
klass_closure->do_klass(k); |
16352
1ff72c6eaa70
8007725: NPG: Klass::restore_unshareable_info() triggers assert(k->java_mirror() == NULL)
coleenp
parents:
15437
diff
changeset
|
331 |
assert(k != k->next_link(), "no loops!"); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
332 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
333 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
334 |
|
18025 | 335 |
void ClassLoaderData::classes_do(void f(Klass * const)) { |
47634
6a0c42c40cd1
8188220: Remove Atomic::*_ptr() uses and overloads from hotspot
coleenp
parents:
47580
diff
changeset
|
336 |
// Lock-free access requires load_acquire |
6a0c42c40cd1
8188220: Remove Atomic::*_ptr() uses and overloads from hotspot
coleenp
parents:
47580
diff
changeset
|
337 |
for (Klass* k = OrderAccess::load_acquire(&_klasses); k != NULL; k = k->next_link()) { |
18025 | 338 |
f(k); |
42639
762117d57d05
8170672: Event-based tracing to support classloader instances
mgronlun
parents:
41727
diff
changeset
|
339 |
assert(k != k->next_link(), "no loops!"); |
18025 | 340 |
} |
341 |
} |
|
342 |
||
23526
6851d341ad52
8037970: make PrintMethodData a diagnostic options
roland
parents:
22905
diff
changeset
|
343 |
void ClassLoaderData::methods_do(void f(Method*)) { |
47634
6a0c42c40cd1
8188220: Remove Atomic::*_ptr() uses and overloads from hotspot
coleenp
parents:
47580
diff
changeset
|
344 |
// Lock-free access requires load_acquire |
6a0c42c40cd1
8188220: Remove Atomic::*_ptr() uses and overloads from hotspot
coleenp
parents:
47580
diff
changeset
|
345 |
for (Klass* k = OrderAccess::load_acquire(&_klasses); k != NULL; k = k->next_link()) { |
46380
4a51438196cf
8026985: Rewrite SystemDictionary::classes_do and Dictionary::classes_do to use KlassClosure
coleenp
parents:
46338
diff
changeset
|
346 |
if (k->is_instance_klass() && InstanceKlass::cast(k)->is_loaded()) { |
23526
6851d341ad52
8037970: make PrintMethodData a diagnostic options
roland
parents:
22905
diff
changeset
|
347 |
InstanceKlass::cast(k)->methods_do(f); |
6851d341ad52
8037970: make PrintMethodData a diagnostic options
roland
parents:
22905
diff
changeset
|
348 |
} |
6851d341ad52
8037970: make PrintMethodData a diagnostic options
roland
parents:
22905
diff
changeset
|
349 |
} |
6851d341ad52
8037970: make PrintMethodData a diagnostic options
roland
parents:
22905
diff
changeset
|
350 |
} |
6851d341ad52
8037970: make PrintMethodData a diagnostic options
roland
parents:
22905
diff
changeset
|
351 |
|
21183
e148e499e5cd
8024423: JVMTI: GetLoadedClasses doesn't enumerate anonymous classes
farvidsson
parents:
20282
diff
changeset
|
352 |
void ClassLoaderData::loaded_classes_do(KlassClosure* klass_closure) { |
47634
6a0c42c40cd1
8188220: Remove Atomic::*_ptr() uses and overloads from hotspot
coleenp
parents:
47580
diff
changeset
|
353 |
// Lock-free access requires load_acquire |
6a0c42c40cd1
8188220: Remove Atomic::*_ptr() uses and overloads from hotspot
coleenp
parents:
47580
diff
changeset
|
354 |
for (Klass* k = OrderAccess::load_acquire(&_klasses); k != NULL; k = k->next_link()) { |
21183
e148e499e5cd
8024423: JVMTI: GetLoadedClasses doesn't enumerate anonymous classes
farvidsson
parents:
20282
diff
changeset
|
355 |
// Do not filter ArrayKlass oops here... |
33611
9abd65805e19
8139203: Consistent naming for klass type predicates
coleenp
parents:
33105
diff
changeset
|
356 |
if (k->is_array_klass() || (k->is_instance_klass() && InstanceKlass::cast(k)->is_loaded())) { |
51962
628909466216
8210926: vmTestbase/nsk/jvmti/scenarios/allocation/AP11/ap11t001/TestDescription.java failed with JVMTI_ERROR_INVALID_CLASS in CDS mode
jiangli
parents:
51959
diff
changeset
|
357 |
#ifdef ASSERT |
628909466216
8210926: vmTestbase/nsk/jvmti/scenarios/allocation/AP11/ap11t001/TestDescription.java failed with JVMTI_ERROR_INVALID_CLASS in CDS mode
jiangli
parents:
51959
diff
changeset
|
358 |
oop m = k->java_mirror(); |
628909466216
8210926: vmTestbase/nsk/jvmti/scenarios/allocation/AP11/ap11t001/TestDescription.java failed with JVMTI_ERROR_INVALID_CLASS in CDS mode
jiangli
parents:
51959
diff
changeset
|
359 |
assert(m != NULL, "NULL mirror"); |
628909466216
8210926: vmTestbase/nsk/jvmti/scenarios/allocation/AP11/ap11t001/TestDescription.java failed with JVMTI_ERROR_INVALID_CLASS in CDS mode
jiangli
parents:
51959
diff
changeset
|
360 |
assert(m->is_a(SystemDictionary::Class_klass()), "invalid mirror"); |
628909466216
8210926: vmTestbase/nsk/jvmti/scenarios/allocation/AP11/ap11t001/TestDescription.java failed with JVMTI_ERROR_INVALID_CLASS in CDS mode
jiangli
parents:
51959
diff
changeset
|
361 |
#endif |
21183
e148e499e5cd
8024423: JVMTI: GetLoadedClasses doesn't enumerate anonymous classes
farvidsson
parents:
20282
diff
changeset
|
362 |
klass_closure->do_klass(k); |
e148e499e5cd
8024423: JVMTI: GetLoadedClasses doesn't enumerate anonymous classes
farvidsson
parents:
20282
diff
changeset
|
363 |
} |
e148e499e5cd
8024423: JVMTI: GetLoadedClasses doesn't enumerate anonymous classes
farvidsson
parents:
20282
diff
changeset
|
364 |
} |
e148e499e5cd
8024423: JVMTI: GetLoadedClasses doesn't enumerate anonymous classes
farvidsson
parents:
20282
diff
changeset
|
365 |
} |
e148e499e5cd
8024423: JVMTI: GetLoadedClasses doesn't enumerate anonymous classes
farvidsson
parents:
20282
diff
changeset
|
366 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
367 |
void ClassLoaderData::classes_do(void f(InstanceKlass*)) { |
47634
6a0c42c40cd1
8188220: Remove Atomic::*_ptr() uses and overloads from hotspot
coleenp
parents:
47580
diff
changeset
|
368 |
// Lock-free access requires load_acquire |
6a0c42c40cd1
8188220: Remove Atomic::*_ptr() uses and overloads from hotspot
coleenp
parents:
47580
diff
changeset
|
369 |
for (Klass* k = OrderAccess::load_acquire(&_klasses); k != NULL; k = k->next_link()) { |
33611
9abd65805e19
8139203: Consistent naming for klass type predicates
coleenp
parents:
33105
diff
changeset
|
370 |
if (k->is_instance_klass()) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
371 |
f(InstanceKlass::cast(k)); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
372 |
} |
16352
1ff72c6eaa70
8007725: NPG: Klass::restore_unshareable_info() triggers assert(k->java_mirror() == NULL)
coleenp
parents:
15437
diff
changeset
|
373 |
assert(k != k->next_link(), "no loops!"); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
374 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
375 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
376 |
|
36508 | 377 |
void ClassLoaderData::modules_do(void f(ModuleEntry*)) { |
38937
2bf3c37c4841
8154750: Add missing OrderAccess operations to ClassLoaderData lock-free data structures
dholmes
parents:
38635
diff
changeset
|
378 |
assert_locked_or_safepoint(Module_lock); |
46387 | 379 |
if (_unnamed_module != NULL) { |
380 |
f(_unnamed_module); |
|
381 |
} |
|
36508 | 382 |
if (_modules != NULL) { |
383 |
for (int i = 0; i < _modules->table_size(); i++) { |
|
384 |
for (ModuleEntry* entry = _modules->bucket(i); |
|
46420
227f72691ac1
8179235: PackageEntryTables should be created eagerly
hseigel
parents:
46387
diff
changeset
|
385 |
entry != NULL; |
227f72691ac1
8179235: PackageEntryTables should be created eagerly
hseigel
parents:
46387
diff
changeset
|
386 |
entry = entry->next()) { |
36508 | 387 |
f(entry); |
388 |
} |
|
389 |
} |
|
390 |
} |
|
391 |
} |
|
392 |
||
393 |
void ClassLoaderData::packages_do(void f(PackageEntry*)) { |
|
46420
227f72691ac1
8179235: PackageEntryTables should be created eagerly
hseigel
parents:
46387
diff
changeset
|
394 |
assert_locked_or_safepoint(Module_lock); |
227f72691ac1
8179235: PackageEntryTables should be created eagerly
hseigel
parents:
46387
diff
changeset
|
395 |
if (_packages != NULL) { |
227f72691ac1
8179235: PackageEntryTables should be created eagerly
hseigel
parents:
46387
diff
changeset
|
396 |
for (int i = 0; i < _packages->table_size(); i++) { |
227f72691ac1
8179235: PackageEntryTables should be created eagerly
hseigel
parents:
46387
diff
changeset
|
397 |
for (PackageEntry* entry = _packages->bucket(i); |
227f72691ac1
8179235: PackageEntryTables should be created eagerly
hseigel
parents:
46387
diff
changeset
|
398 |
entry != NULL; |
227f72691ac1
8179235: PackageEntryTables should be created eagerly
hseigel
parents:
46387
diff
changeset
|
399 |
entry = entry->next()) { |
36508 | 400 |
f(entry); |
401 |
} |
|
402 |
} |
|
403 |
} |
|
404 |
} |
|
405 |
||
49348
fde3feaaa4ed
8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents:
49041
diff
changeset
|
406 |
void ClassLoaderData::record_dependency(const Klass* k) { |
34666 | 407 |
assert(k != NULL, "invariant"); |
408 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
409 |
ClassLoaderData * const from_cld = this; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
410 |
ClassLoaderData * const to_cld = k->class_loader_data(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
411 |
|
48860
5bce1b7e7800
8190359: Reduce the number of recorded klass dependencies
hseigel
parents:
48811
diff
changeset
|
412 |
// Do not need to record dependency if the dependency is to a class whose |
5bce1b7e7800
8190359: Reduce the number of recorded klass dependencies
hseigel
parents:
48811
diff
changeset
|
413 |
// class loader data is never freed. (i.e. the dependency's class loader |
5bce1b7e7800
8190359: Reduce the number of recorded klass dependencies
hseigel
parents:
48811
diff
changeset
|
414 |
// is one of the three builtin class loaders and the dependency is not |
51444
3e5d28e6de32
8209301: JVM rename is_anonymous, host_klass to unsafe specific terminology ahead of Unsafe.defineAnonymousClass deprecation
lfoltan
parents:
51415
diff
changeset
|
415 |
// unsafe anonymous.) |
48860
5bce1b7e7800
8190359: Reduce the number of recorded klass dependencies
hseigel
parents:
48811
diff
changeset
|
416 |
if (to_cld->is_permanent_class_loader_data()) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
417 |
return; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
418 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
419 |
|
14588
8ec26d2d9339
8000662: NPG: nashorn ant clean test262 out-of-memory with Java heap
coleenp
parents:
13728
diff
changeset
|
420 |
oop to; |
51444
3e5d28e6de32
8209301: JVM rename is_anonymous, host_klass to unsafe specific terminology ahead of Unsafe.defineAnonymousClass deprecation
lfoltan
parents:
51415
diff
changeset
|
421 |
if (to_cld->is_unsafe_anonymous()) { |
3e5d28e6de32
8209301: JVM rename is_anonymous, host_klass to unsafe specific terminology ahead of Unsafe.defineAnonymousClass deprecation
lfoltan
parents:
51415
diff
changeset
|
422 |
// Just return if an unsafe anonymous class is attempting to record a dependency |
3e5d28e6de32
8209301: JVM rename is_anonymous, host_klass to unsafe specific terminology ahead of Unsafe.defineAnonymousClass deprecation
lfoltan
parents:
51415
diff
changeset
|
423 |
// to itself. (Note that every unsafe anonymous class has its own unique class |
48860
5bce1b7e7800
8190359: Reduce the number of recorded klass dependencies
hseigel
parents:
48811
diff
changeset
|
424 |
// loader data.) |
5bce1b7e7800
8190359: Reduce the number of recorded klass dependencies
hseigel
parents:
48811
diff
changeset
|
425 |
if (to_cld == from_cld) { |
5bce1b7e7800
8190359: Reduce the number of recorded klass dependencies
hseigel
parents:
48811
diff
changeset
|
426 |
return; |
5bce1b7e7800
8190359: Reduce the number of recorded klass dependencies
hseigel
parents:
48811
diff
changeset
|
427 |
} |
51444
3e5d28e6de32
8209301: JVM rename is_anonymous, host_klass to unsafe specific terminology ahead of Unsafe.defineAnonymousClass deprecation
lfoltan
parents:
51415
diff
changeset
|
428 |
// Unsafe anonymous class dependencies are through the mirror. |
14588
8ec26d2d9339
8000662: NPG: nashorn ant clean test262 out-of-memory with Java heap
coleenp
parents:
13728
diff
changeset
|
429 |
to = k->java_mirror(); |
8ec26d2d9339
8000662: NPG: nashorn ant clean test262 out-of-memory with Java heap
coleenp
parents:
13728
diff
changeset
|
430 |
} else { |
8ec26d2d9339
8000662: NPG: nashorn ant clean test262 out-of-memory with Java heap
coleenp
parents:
13728
diff
changeset
|
431 |
to = to_cld->class_loader(); |
48860
5bce1b7e7800
8190359: Reduce the number of recorded klass dependencies
hseigel
parents:
48811
diff
changeset
|
432 |
oop from = from_cld->class_loader(); |
14588
8ec26d2d9339
8000662: NPG: nashorn ant clean test262 out-of-memory with Java heap
coleenp
parents:
13728
diff
changeset
|
433 |
|
48860
5bce1b7e7800
8190359: Reduce the number of recorded klass dependencies
hseigel
parents:
48811
diff
changeset
|
434 |
// Just return if this dependency is to a class with the same or a parent |
5bce1b7e7800
8190359: Reduce the number of recorded klass dependencies
hseigel
parents:
48811
diff
changeset
|
435 |
// class_loader. |
58177 | 436 |
if (from == to || java_lang_ClassLoader::isAncestor(from, to)) { |
48860
5bce1b7e7800
8190359: Reduce the number of recorded klass dependencies
hseigel
parents:
48811
diff
changeset
|
437 |
return; // this class loader is in the parent list, no need to add it. |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
438 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
439 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
440 |
|
49348
fde3feaaa4ed
8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents:
49041
diff
changeset
|
441 |
// It's a dependency we won't find through GC, add it. |
fde3feaaa4ed
8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents:
49041
diff
changeset
|
442 |
if (!_handles.contains(to)) { |
fde3feaaa4ed
8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents:
49041
diff
changeset
|
443 |
NOT_PRODUCT(Atomic::inc(&_dependency_count)); |
fde3feaaa4ed
8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents:
49041
diff
changeset
|
444 |
LogTarget(Trace, class, loader, data) lt; |
fde3feaaa4ed
8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents:
49041
diff
changeset
|
445 |
if (lt.is_enabled()) { |
fde3feaaa4ed
8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents:
49041
diff
changeset
|
446 |
ResourceMark rm; |
fde3feaaa4ed
8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents:
49041
diff
changeset
|
447 |
LogStream ls(lt); |
fde3feaaa4ed
8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents:
49041
diff
changeset
|
448 |
ls.print("adding dependency from "); |
fde3feaaa4ed
8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents:
49041
diff
changeset
|
449 |
print_value_on(&ls); |
fde3feaaa4ed
8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents:
49041
diff
changeset
|
450 |
ls.print(" to "); |
fde3feaaa4ed
8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents:
49041
diff
changeset
|
451 |
to_cld->print_value_on(&ls); |
fde3feaaa4ed
8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents:
49041
diff
changeset
|
452 |
ls.cr(); |
fde3feaaa4ed
8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents:
49041
diff
changeset
|
453 |
} |
fde3feaaa4ed
8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents:
49041
diff
changeset
|
454 |
Handle dependency(Thread::current(), to); |
fde3feaaa4ed
8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents:
49041
diff
changeset
|
455 |
add_handle(dependency); |
fde3feaaa4ed
8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents:
49041
diff
changeset
|
456 |
// Added a potentially young gen oop to the ClassLoaderData |
fde3feaaa4ed
8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents:
49041
diff
changeset
|
457 |
record_modified_oops(); |
fde3feaaa4ed
8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents:
49041
diff
changeset
|
458 |
} |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
459 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
460 |
|
34666 | 461 |
void ClassLoaderData::add_class(Klass* k, bool publicize /* true */) { |
462 |
{ |
|
54623
1126f0607c70
8222811: Consolidate MutexLockerEx and MutexLocker
coleenp
parents:
54343
diff
changeset
|
463 |
MutexLocker ml(metaspace_lock(), Mutex::_no_safepoint_check_flag); |
34666 | 464 |
Klass* old_value = _klasses; |
465 |
k->set_next_link(old_value); |
|
38937
2bf3c37c4841
8154750: Add missing OrderAccess operations to ClassLoaderData lock-free data structures
dholmes
parents:
38635
diff
changeset
|
466 |
// Link the new item into the list, making sure the linked class is stable |
2bf3c37c4841
8154750: Add missing OrderAccess operations to ClassLoaderData lock-free data structures
dholmes
parents:
38635
diff
changeset
|
467 |
// since the list can be walked without a lock |
47634
6a0c42c40cd1
8188220: Remove Atomic::*_ptr() uses and overloads from hotspot
coleenp
parents:
47580
diff
changeset
|
468 |
OrderAccess::release_store(&_klasses, k); |
48884
7e17b00dc245
8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents:
48874
diff
changeset
|
469 |
if (k->is_array_klass()) { |
7e17b00dc245
8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents:
48874
diff
changeset
|
470 |
ClassLoaderDataGraph::inc_array_classes(1); |
7e17b00dc245
8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents:
48874
diff
changeset
|
471 |
} else { |
7e17b00dc245
8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents:
48874
diff
changeset
|
472 |
ClassLoaderDataGraph::inc_instance_classes(1); |
7e17b00dc245
8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents:
48874
diff
changeset
|
473 |
} |
34666 | 474 |
} |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
475 |
|
49348
fde3feaaa4ed
8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents:
49041
diff
changeset
|
476 |
if (publicize) { |
fde3feaaa4ed
8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents:
49041
diff
changeset
|
477 |
LogTarget(Trace, class, loader, data) lt; |
fde3feaaa4ed
8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents:
49041
diff
changeset
|
478 |
if (lt.is_enabled()) { |
fde3feaaa4ed
8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents:
49041
diff
changeset
|
479 |
ResourceMark rm; |
fde3feaaa4ed
8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents:
49041
diff
changeset
|
480 |
LogStream ls(lt); |
fde3feaaa4ed
8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents:
49041
diff
changeset
|
481 |
ls.print("Adding k: " PTR_FORMAT " %s to ", p2i(k), k->external_name()); |
fde3feaaa4ed
8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents:
49041
diff
changeset
|
482 |
print_value_on(&ls); |
fde3feaaa4ed
8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents:
49041
diff
changeset
|
483 |
ls.cr(); |
fde3feaaa4ed
8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents:
49041
diff
changeset
|
484 |
} |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
485 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
486 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
487 |
|
49738
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
49658
diff
changeset
|
488 |
void ClassLoaderData::initialize_holder(Handle loader_or_mirror) { |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
49658
diff
changeset
|
489 |
if (loader_or_mirror() != NULL) { |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
49658
diff
changeset
|
490 |
assert(_holder.is_null(), "never replace holders"); |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
49658
diff
changeset
|
491 |
_holder = WeakHandle<vm_class_loader_data>::create(loader_or_mirror); |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
49658
diff
changeset
|
492 |
} |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
49658
diff
changeset
|
493 |
} |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
49658
diff
changeset
|
494 |
|
38937
2bf3c37c4841
8154750: Add missing OrderAccess operations to ClassLoaderData lock-free data structures
dholmes
parents:
38635
diff
changeset
|
495 |
// Remove a klass from the _klasses list for scratch_class during redefinition |
2bf3c37c4841
8154750: Add missing OrderAccess operations to ClassLoaderData lock-free data structures
dholmes
parents:
38635
diff
changeset
|
496 |
// or parsed class in the case of an error. |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
497 |
void ClassLoaderData::remove_class(Klass* scratch_class) { |
52587
6cd56deebb0d
8213092: Add more runtime locks for concurrent class unloading
coleenp
parents:
52141
diff
changeset
|
498 |
assert_locked_or_safepoint(ClassLoaderDataGraph_lock); |
46729 | 499 |
|
500 |
// Adjust global class iterator. |
|
51959
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
51887
diff
changeset
|
501 |
ClassLoaderDataGraph::adjust_saved_class(scratch_class); |
46729 | 502 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
503 |
Klass* prev = NULL; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
504 |
for (Klass* k = _klasses; k != NULL; k = k->next_link()) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
505 |
if (k == scratch_class) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
506 |
if (prev == NULL) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
507 |
_klasses = k->next_link(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
508 |
} else { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
509 |
Klass* next = k->next_link(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
510 |
prev->set_next_link(next); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
511 |
} |
48884
7e17b00dc245
8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents:
48874
diff
changeset
|
512 |
|
7e17b00dc245
8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents:
48874
diff
changeset
|
513 |
if (k->is_array_klass()) { |
7e17b00dc245
8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents:
48874
diff
changeset
|
514 |
ClassLoaderDataGraph::dec_array_classes(1); |
7e17b00dc245
8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents:
48874
diff
changeset
|
515 |
} else { |
7e17b00dc245
8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents:
48874
diff
changeset
|
516 |
ClassLoaderDataGraph::dec_instance_classes(1); |
7e17b00dc245
8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents:
48874
diff
changeset
|
517 |
} |
7e17b00dc245
8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents:
48874
diff
changeset
|
518 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
519 |
return; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
520 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
521 |
prev = k; |
16352
1ff72c6eaa70
8007725: NPG: Klass::restore_unshareable_info() triggers assert(k->java_mirror() == NULL)
coleenp
parents:
15437
diff
changeset
|
522 |
assert(k != k->next_link(), "no loops!"); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
523 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
524 |
ShouldNotReachHere(); // should have found this class!! |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
525 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
526 |
|
14588
8ec26d2d9339
8000662: NPG: nashorn ant clean test262 out-of-memory with Java heap
coleenp
parents:
13728
diff
changeset
|
527 |
void ClassLoaderData::unload() { |
8ec26d2d9339
8000662: NPG: nashorn ant clean test262 out-of-memory with Java heap
coleenp
parents:
13728
diff
changeset
|
528 |
_unloading = true; |
8ec26d2d9339
8000662: NPG: nashorn ant clean test262 out-of-memory with Java heap
coleenp
parents:
13728
diff
changeset
|
529 |
|
51338
aa3bfacc912c
8208677: Move inner metaspace cleaning out of class unloading
coleenp
parents:
51334
diff
changeset
|
530 |
LogTarget(Trace, class, loader, data) lt; |
46701
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46464
diff
changeset
|
531 |
if (lt.is_enabled()) { |
14588
8ec26d2d9339
8000662: NPG: nashorn ant clean test262 out-of-memory with Java heap
coleenp
parents:
13728
diff
changeset
|
532 |
ResourceMark rm; |
46701
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46464
diff
changeset
|
533 |
LogStream ls(lt); |
49824
e242740a92b8
8201556: Disallow reading oops in ClassLoaderData if unloading
coleenp
parents:
49818
diff
changeset
|
534 |
ls.print("unload"); |
49348
fde3feaaa4ed
8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents:
49041
diff
changeset
|
535 |
print_value_on(&ls); |
46701
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46464
diff
changeset
|
536 |
ls.cr(); |
14588
8ec26d2d9339
8000662: NPG: nashorn ant clean test262 out-of-memory with Java heap
coleenp
parents:
13728
diff
changeset
|
537 |
} |
38635
e15e221b60a0
8135322: ConstantPool::release_C_heap_structures not run in some circumstances
aeriksso
parents:
38151
diff
changeset
|
538 |
|
48395 | 539 |
// Some items on the _deallocate_list need to free their C heap structures |
540 |
// if they are not already on the _klasses list. |
|
51338
aa3bfacc912c
8208677: Move inner metaspace cleaning out of class unloading
coleenp
parents:
51334
diff
changeset
|
541 |
free_deallocate_list_C_heap_structures(); |
46729 | 542 |
|
51887
32161fbea3fe
8210856: Move InstanceKlass DependencyContext cleaning to SystemDictionary::do_unloading()
coleenp
parents:
51747
diff
changeset
|
543 |
// Clean up class dependencies and tell serviceability tools |
32161fbea3fe
8210856: Move InstanceKlass DependencyContext cleaning to SystemDictionary::do_unloading()
coleenp
parents:
51747
diff
changeset
|
544 |
// these classes are unloading. Must be called |
50219
4ab066d71956
8202669: Intermittent crash in ClassLoadingService::compute_class_size()
coleenp
parents:
50113
diff
changeset
|
545 |
// after erroneous classes are released. |
51887
32161fbea3fe
8210856: Move InstanceKlass DependencyContext cleaning to SystemDictionary::do_unloading()
coleenp
parents:
51747
diff
changeset
|
546 |
classes_do(InstanceKlass::unload_class); |
50219
4ab066d71956
8202669: Intermittent crash in ClassLoadingService::compute_class_size()
coleenp
parents:
50113
diff
changeset
|
547 |
|
46729 | 548 |
// Clean up global class iterator for compiler |
51959
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
51887
diff
changeset
|
549 |
ClassLoaderDataGraph::adjust_saved_class(this); |
14588
8ec26d2d9339
8000662: NPG: nashorn ant clean test262 out-of-memory with Java heap
coleenp
parents:
13728
diff
changeset
|
550 |
} |
8ec26d2d9339
8000662: NPG: nashorn ant clean test262 out-of-memory with Java heap
coleenp
parents:
13728
diff
changeset
|
551 |
|
36508 | 552 |
ModuleEntryTable* ClassLoaderData::modules() { |
553 |
// Lazily create the module entry table at first request. |
|
47634
6a0c42c40cd1
8188220: Remove Atomic::*_ptr() uses and overloads from hotspot
coleenp
parents:
47580
diff
changeset
|
554 |
// Lock-free access requires load_acquire. |
6a0c42c40cd1
8188220: Remove Atomic::*_ptr() uses and overloads from hotspot
coleenp
parents:
47580
diff
changeset
|
555 |
ModuleEntryTable* modules = OrderAccess::load_acquire(&_modules); |
38937
2bf3c37c4841
8154750: Add missing OrderAccess operations to ClassLoaderData lock-free data structures
dholmes
parents:
38635
diff
changeset
|
556 |
if (modules == NULL) { |
36508 | 557 |
MutexLocker m1(Module_lock); |
38937
2bf3c37c4841
8154750: Add missing OrderAccess operations to ClassLoaderData lock-free data structures
dholmes
parents:
38635
diff
changeset
|
558 |
// Check if _modules got allocated while we were waiting for this lock. |
2bf3c37c4841
8154750: Add missing OrderAccess operations to ClassLoaderData lock-free data structures
dholmes
parents:
38635
diff
changeset
|
559 |
if ((modules = _modules) == NULL) { |
2bf3c37c4841
8154750: Add missing OrderAccess operations to ClassLoaderData lock-free data structures
dholmes
parents:
38635
diff
changeset
|
560 |
modules = new ModuleEntryTable(ModuleEntryTable::_moduletable_entry_size); |
36508 | 561 |
|
38937
2bf3c37c4841
8154750: Add missing OrderAccess operations to ClassLoaderData lock-free data structures
dholmes
parents:
38635
diff
changeset
|
562 |
{ |
54623
1126f0607c70
8222811: Consolidate MutexLockerEx and MutexLocker
coleenp
parents:
54343
diff
changeset
|
563 |
MutexLocker m1(metaspace_lock(), Mutex::_no_safepoint_check_flag); |
38937
2bf3c37c4841
8154750: Add missing OrderAccess operations to ClassLoaderData lock-free data structures
dholmes
parents:
38635
diff
changeset
|
564 |
// Ensure _modules is stable, since it is examined without a lock |
47634
6a0c42c40cd1
8188220: Remove Atomic::*_ptr() uses and overloads from hotspot
coleenp
parents:
47580
diff
changeset
|
565 |
OrderAccess::release_store(&_modules, modules); |
38937
2bf3c37c4841
8154750: Add missing OrderAccess operations to ClassLoaderData lock-free data structures
dholmes
parents:
38635
diff
changeset
|
566 |
} |
36508 | 567 |
} |
568 |
} |
|
38937
2bf3c37c4841
8154750: Add missing OrderAccess operations to ClassLoaderData lock-free data structures
dholmes
parents:
38635
diff
changeset
|
569 |
return modules; |
36508 | 570 |
} |
571 |
||
46729 | 572 |
const int _boot_loader_dictionary_size = 1009; |
573 |
const int _default_loader_dictionary_size = 107; |
|
574 |
||
575 |
Dictionary* ClassLoaderData::create_dictionary() { |
|
51444
3e5d28e6de32
8209301: JVM rename is_anonymous, host_klass to unsafe specific terminology ahead of Unsafe.defineAnonymousClass deprecation
lfoltan
parents:
51415
diff
changeset
|
576 |
assert(!is_unsafe_anonymous(), "unsafe anonymous class loader data do not have a dictionary"); |
46729 | 577 |
int size; |
47774 | 578 |
bool resizable = false; |
46729 | 579 |
if (_the_null_class_loader_data == NULL) { |
580 |
size = _boot_loader_dictionary_size; |
|
47774 | 581 |
resizable = true; |
46729 | 582 |
} else if (class_loader()->is_a(SystemDictionary::reflect_DelegatingClassLoader_klass())) { |
583 |
size = 1; // there's only one class in relection class loader and no initiated classes |
|
584 |
} else if (is_system_class_loader_data()) { |
|
47774 | 585 |
size = _boot_loader_dictionary_size; |
586 |
resizable = true; |
|
46729 | 587 |
} else { |
588 |
size = _default_loader_dictionary_size; |
|
47774 | 589 |
resizable = true; |
46729 | 590 |
} |
51523
73523d329966
8208061: runtime/LoadClass/TestResize.java fails with "Load factor too high" when running in CDS mode.
jiangli
parents:
51471
diff
changeset
|
591 |
if (!DynamicallyResizeSystemDictionaries || DumpSharedSpaces) { |
47774 | 592 |
resizable = false; |
593 |
} |
|
594 |
return new Dictionary(this, size, resizable); |
|
46729 | 595 |
} |
596 |
||
49479
5865398439d4
8197844: JVMTI GetLoadedClasses should use the Access API
coleenp
parents:
49403
diff
changeset
|
597 |
// Tell the GC to keep this klass alive while iterating ClassLoaderDataGraph |
49738
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
49658
diff
changeset
|
598 |
oop ClassLoaderData::holder_phantom() const { |
49479
5865398439d4
8197844: JVMTI GetLoadedClasses should use the Access API
coleenp
parents:
49403
diff
changeset
|
599 |
// A klass that was previously considered dead can be looked up in the |
5865398439d4
8197844: JVMTI GetLoadedClasses should use the Access API
coleenp
parents:
49403
diff
changeset
|
600 |
// CLD/SD, and its _java_mirror or _class_loader can be stored in a root |
5865398439d4
8197844: JVMTI GetLoadedClasses should use the Access API
coleenp
parents:
49403
diff
changeset
|
601 |
// or a reachable object making it alive again. The SATB part of G1 needs |
5865398439d4
8197844: JVMTI GetLoadedClasses should use the Access API
coleenp
parents:
49403
diff
changeset
|
602 |
// to get notified about this potential resurrection, otherwise the marking |
5865398439d4
8197844: JVMTI GetLoadedClasses should use the Access API
coleenp
parents:
49403
diff
changeset
|
603 |
// might not find the object. |
49738
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
49658
diff
changeset
|
604 |
if (!_holder.is_null()) { // NULL class_loader |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
49658
diff
changeset
|
605 |
return _holder.resolve(); |
49479
5865398439d4
8197844: JVMTI GetLoadedClasses should use the Access API
coleenp
parents:
49403
diff
changeset
|
606 |
} else { |
5865398439d4
8197844: JVMTI GetLoadedClasses should use the Access API
coleenp
parents:
49403
diff
changeset
|
607 |
return NULL; |
5865398439d4
8197844: JVMTI GetLoadedClasses should use the Access API
coleenp
parents:
49403
diff
changeset
|
608 |
} |
5865398439d4
8197844: JVMTI GetLoadedClasses should use the Access API
coleenp
parents:
49403
diff
changeset
|
609 |
} |
5865398439d4
8197844: JVMTI GetLoadedClasses should use the Access API
coleenp
parents:
49403
diff
changeset
|
610 |
|
51682
a30461a359f5
8210321: Create NO_KEEPALIVE CLD holder accessor
eosterlund
parents:
51608
diff
changeset
|
611 |
// Let the GC read the holder without keeping it alive. |
a30461a359f5
8210321: Create NO_KEEPALIVE CLD holder accessor
eosterlund
parents:
51608
diff
changeset
|
612 |
oop ClassLoaderData::holder_no_keepalive() const { |
a30461a359f5
8210321: Create NO_KEEPALIVE CLD holder accessor
eosterlund
parents:
51608
diff
changeset
|
613 |
if (!_holder.is_null()) { // NULL class_loader |
a30461a359f5
8210321: Create NO_KEEPALIVE CLD holder accessor
eosterlund
parents:
51608
diff
changeset
|
614 |
return _holder.peek(); |
a30461a359f5
8210321: Create NO_KEEPALIVE CLD holder accessor
eosterlund
parents:
51608
diff
changeset
|
615 |
} else { |
a30461a359f5
8210321: Create NO_KEEPALIVE CLD holder accessor
eosterlund
parents:
51608
diff
changeset
|
616 |
return NULL; |
a30461a359f5
8210321: Create NO_KEEPALIVE CLD holder accessor
eosterlund
parents:
51608
diff
changeset
|
617 |
} |
a30461a359f5
8210321: Create NO_KEEPALIVE CLD holder accessor
eosterlund
parents:
51608
diff
changeset
|
618 |
} |
a30461a359f5
8210321: Create NO_KEEPALIVE CLD holder accessor
eosterlund
parents:
51608
diff
changeset
|
619 |
|
46729 | 620 |
// Unloading support |
49738
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
49658
diff
changeset
|
621 |
bool ClassLoaderData::is_alive() const { |
51444
3e5d28e6de32
8209301: JVM rename is_anonymous, host_klass to unsafe specific terminology ahead of Unsafe.defineAnonymousClass deprecation
lfoltan
parents:
51415
diff
changeset
|
622 |
bool alive = keep_alive() // null class loader and incomplete unsafe anonymous klasses. |
49824
e242740a92b8
8201556: Disallow reading oops in ClassLoaderData if unloading
coleenp
parents:
49818
diff
changeset
|
623 |
|| (_holder.peek() != NULL); // and not cleaned by the GC weak handle processing. |
22900 | 624 |
|
14588
8ec26d2d9339
8000662: NPG: nashorn ant clean test262 out-of-memory with Java heap
coleenp
parents:
13728
diff
changeset
|
625 |
return alive; |
8ec26d2d9339
8000662: NPG: nashorn ant clean test262 out-of-memory with Java heap
coleenp
parents:
13728
diff
changeset
|
626 |
} |
8ec26d2d9339
8000662: NPG: nashorn ant clean test262 out-of-memory with Java heap
coleenp
parents:
13728
diff
changeset
|
627 |
|
48884
7e17b00dc245
8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents:
48874
diff
changeset
|
628 |
class ReleaseKlassClosure: public KlassClosure { |
7e17b00dc245
8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents:
48874
diff
changeset
|
629 |
private: |
7e17b00dc245
8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents:
48874
diff
changeset
|
630 |
size_t _instance_class_released; |
7e17b00dc245
8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents:
48874
diff
changeset
|
631 |
size_t _array_class_released; |
7e17b00dc245
8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents:
48874
diff
changeset
|
632 |
public: |
7e17b00dc245
8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents:
48874
diff
changeset
|
633 |
ReleaseKlassClosure() : _instance_class_released(0), _array_class_released(0) { } |
7e17b00dc245
8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents:
48874
diff
changeset
|
634 |
|
7e17b00dc245
8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents:
48874
diff
changeset
|
635 |
size_t instance_class_released() const { return _instance_class_released; } |
7e17b00dc245
8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents:
48874
diff
changeset
|
636 |
size_t array_class_released() const { return _array_class_released; } |
7e17b00dc245
8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents:
48874
diff
changeset
|
637 |
|
7e17b00dc245
8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents:
48874
diff
changeset
|
638 |
void do_klass(Klass* k) { |
7e17b00dc245
8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents:
48874
diff
changeset
|
639 |
if (k->is_array_klass()) { |
7e17b00dc245
8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents:
48874
diff
changeset
|
640 |
_array_class_released ++; |
7e17b00dc245
8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents:
48874
diff
changeset
|
641 |
} else { |
7e17b00dc245
8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents:
48874
diff
changeset
|
642 |
assert(k->is_instance_klass(), "Must be"); |
7e17b00dc245
8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents:
48874
diff
changeset
|
643 |
_instance_class_released ++; |
7e17b00dc245
8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents:
48874
diff
changeset
|
644 |
InstanceKlass::release_C_heap_structures(InstanceKlass::cast(k)); |
7e17b00dc245
8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents:
48874
diff
changeset
|
645 |
} |
7e17b00dc245
8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents:
48874
diff
changeset
|
646 |
} |
7e17b00dc245
8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents:
48874
diff
changeset
|
647 |
}; |
7e17b00dc245
8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents:
48874
diff
changeset
|
648 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
649 |
ClassLoaderData::~ClassLoaderData() { |
17075
b53332c50aba
8011803: release_C_heap_structures is never called for anonymous classes.
coleenp
parents:
16684
diff
changeset
|
650 |
// Release C heap structures for all the classes. |
48884
7e17b00dc245
8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents:
48874
diff
changeset
|
651 |
ReleaseKlassClosure cl; |
7e17b00dc245
8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents:
48874
diff
changeset
|
652 |
classes_do(&cl); |
7e17b00dc245
8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents:
48874
diff
changeset
|
653 |
|
7e17b00dc245
8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents:
48874
diff
changeset
|
654 |
ClassLoaderDataGraph::dec_array_classes(cl.array_class_released()); |
7e17b00dc245
8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents:
48874
diff
changeset
|
655 |
ClassLoaderDataGraph::dec_instance_classes(cl.instance_class_released()); |
17075
b53332c50aba
8011803: release_C_heap_structures is never called for anonymous classes.
coleenp
parents:
16684
diff
changeset
|
656 |
|
49738
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
49658
diff
changeset
|
657 |
// Release the WeakHandle |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
49658
diff
changeset
|
658 |
_holder.release(); |
a7bc87a63dd8
8198313: Wrap holder object for ClassLoaderData in a WeakHandle
coleenp
parents:
49658
diff
changeset
|
659 |
|
36508 | 660 |
// Release C heap allocated hashtable for all the packages. |
661 |
if (_packages != NULL) { |
|
662 |
// Destroy the table itself |
|
663 |
delete _packages; |
|
664 |
_packages = NULL; |
|
665 |
} |
|
666 |
||
667 |
// Release C heap allocated hashtable for all the modules. |
|
668 |
if (_modules != NULL) { |
|
669 |
// Destroy the table itself |
|
670 |
delete _modules; |
|
671 |
_modules = NULL; |
|
672 |
} |
|
673 |
||
46729 | 674 |
// Release C heap allocated hashtable for the dictionary |
675 |
if (_dictionary != NULL) { |
|
676 |
// Destroy the table itself |
|
677 |
delete _dictionary; |
|
678 |
_dictionary = NULL; |
|
679 |
} |
|
680 |
||
46387 | 681 |
if (_unnamed_module != NULL) { |
682 |
_unnamed_module->delete_unnamed_module(); |
|
683 |
_unnamed_module = NULL; |
|
684 |
} |
|
685 |
||
36508 | 686 |
// release the metaspace |
49401
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49393
diff
changeset
|
687 |
ClassLoaderMetaspace *m = _metaspace; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
688 |
if (m != NULL) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
689 |
_metaspace = NULL; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
690 |
delete m; |
36508 | 691 |
} |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
692 |
// Clear all the JNI handles for methods |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
693 |
// These aren't deallocated and are going to look like a leak, but that's |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
694 |
// needed because we can't really get rid of jmethodIDs because we don't |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
695 |
// know when native code is going to stop using them. The spec says that |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
696 |
// they're "invalid" but existing programs likely rely on their being |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
697 |
// NULL after class unloading. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
698 |
if (_jmethod_ids != NULL) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
699 |
Method::clear_jmethod_ids(this); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
700 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
701 |
// Delete lock |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
702 |
delete _metaspace_lock; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
703 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
704 |
// Delete free list |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
705 |
if (_deallocate_list != NULL) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
706 |
delete _deallocate_list; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
707 |
} |
51747 | 708 |
|
709 |
// Decrement refcounts of Symbols if created. |
|
710 |
if (_name != NULL) { |
|
711 |
_name->decrement_refcount(); |
|
712 |
} |
|
713 |
if (_name_and_id != NULL) { |
|
714 |
_name_and_id->decrement_refcount(); |
|
715 |
} |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
716 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
717 |
|
48871
120d6893f32f
8190235: Clarify ClassLoaderData::is_*_class_loader_data() method implementations
hseigel
parents:
48860
diff
changeset
|
718 |
// Returns true if this class loader data is for the app class loader |
120d6893f32f
8190235: Clarify ClassLoaderData::is_*_class_loader_data() method implementations
hseigel
parents:
48860
diff
changeset
|
719 |
// or a user defined system class loader. (Note that the class loader |
51444
3e5d28e6de32
8209301: JVM rename is_anonymous, host_klass to unsafe specific terminology ahead of Unsafe.defineAnonymousClass deprecation
lfoltan
parents:
51415
diff
changeset
|
720 |
// data may be unsafe anonymous.) |
39616
f82b1f888578
8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents:
38937
diff
changeset
|
721 |
bool ClassLoaderData::is_system_class_loader_data() const { |
f82b1f888578
8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents:
38937
diff
changeset
|
722 |
return SystemDictionary::is_system_class_loader(class_loader()); |
f82b1f888578
8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents:
38937
diff
changeset
|
723 |
} |
f82b1f888578
8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents:
38937
diff
changeset
|
724 |
|
f82b1f888578
8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents:
38937
diff
changeset
|
725 |
// Returns true if this class loader data is for the platform class loader. |
51444
3e5d28e6de32
8209301: JVM rename is_anonymous, host_klass to unsafe specific terminology ahead of Unsafe.defineAnonymousClass deprecation
lfoltan
parents:
51415
diff
changeset
|
726 |
// (Note that the class loader data may be unsafe anonymous.) |
36508 | 727 |
bool ClassLoaderData::is_platform_class_loader_data() const { |
728 |
return SystemDictionary::is_platform_class_loader(class_loader()); |
|
16617
6235d2c7549f
7198429: need checked categorization of caller-sensitive methods in the JDK
twisti
parents:
16352
diff
changeset
|
729 |
} |
6235d2c7549f
7198429: need checked categorization of caller-sensitive methods in the JDK
twisti
parents:
16352
diff
changeset
|
730 |
|
48871
120d6893f32f
8190235: Clarify ClassLoaderData::is_*_class_loader_data() method implementations
hseigel
parents:
48860
diff
changeset
|
731 |
// Returns true if the class loader for this class loader data is one of |
120d6893f32f
8190235: Clarify ClassLoaderData::is_*_class_loader_data() method implementations
hseigel
parents:
48860
diff
changeset
|
732 |
// the 3 builtin (boot application/system or platform) class loaders, |
120d6893f32f
8190235: Clarify ClassLoaderData::is_*_class_loader_data() method implementations
hseigel
parents:
48860
diff
changeset
|
733 |
// including a user-defined system class loader. Note that if the class |
51444
3e5d28e6de32
8209301: JVM rename is_anonymous, host_klass to unsafe specific terminology ahead of Unsafe.defineAnonymousClass deprecation
lfoltan
parents:
51415
diff
changeset
|
734 |
// loader data is for an unsafe anonymous class then it may get freed by a GC |
48871
120d6893f32f
8190235: Clarify ClassLoaderData::is_*_class_loader_data() method implementations
hseigel
parents:
48860
diff
changeset
|
735 |
// even if its class loader is one of these loaders. |
39616
f82b1f888578
8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents:
38937
diff
changeset
|
736 |
bool ClassLoaderData::is_builtin_class_loader_data() const { |
48871
120d6893f32f
8190235: Clarify ClassLoaderData::is_*_class_loader_data() method implementations
hseigel
parents:
48860
diff
changeset
|
737 |
return (is_boot_class_loader_data() || |
46271
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
42639
diff
changeset
|
738 |
SystemDictionary::is_system_class_loader(class_loader()) || |
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
42639
diff
changeset
|
739 |
SystemDictionary::is_platform_class_loader(class_loader())); |
39616
f82b1f888578
8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents:
38937
diff
changeset
|
740 |
} |
f82b1f888578
8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents:
38937
diff
changeset
|
741 |
|
48860
5bce1b7e7800
8190359: Reduce the number of recorded klass dependencies
hseigel
parents:
48811
diff
changeset
|
742 |
// Returns true if this class loader data is a class loader data |
51444
3e5d28e6de32
8209301: JVM rename is_anonymous, host_klass to unsafe specific terminology ahead of Unsafe.defineAnonymousClass deprecation
lfoltan
parents:
51415
diff
changeset
|
743 |
// that is not ever freed by a GC. It must be the CLD for one of the builtin |
3e5d28e6de32
8209301: JVM rename is_anonymous, host_klass to unsafe specific terminology ahead of Unsafe.defineAnonymousClass deprecation
lfoltan
parents:
51415
diff
changeset
|
744 |
// class loaders and not the CLD for an unsafe anonymous class. |
48860
5bce1b7e7800
8190359: Reduce the number of recorded klass dependencies
hseigel
parents:
48811
diff
changeset
|
745 |
bool ClassLoaderData::is_permanent_class_loader_data() const { |
51444
3e5d28e6de32
8209301: JVM rename is_anonymous, host_klass to unsafe specific terminology ahead of Unsafe.defineAnonymousClass deprecation
lfoltan
parents:
51415
diff
changeset
|
746 |
return is_builtin_class_loader_data() && !is_unsafe_anonymous(); |
48860
5bce1b7e7800
8190359: Reduce the number of recorded klass dependencies
hseigel
parents:
48811
diff
changeset
|
747 |
} |
5bce1b7e7800
8190359: Reduce the number of recorded klass dependencies
hseigel
parents:
48811
diff
changeset
|
748 |
|
49401
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49393
diff
changeset
|
749 |
ClassLoaderMetaspace* ClassLoaderData::metaspace_non_null() { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
750 |
// If the metaspace has not been allocated, create a new one. Might want |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
751 |
// to create smaller arena for Reflection class loaders also. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
752 |
// The reason for the delayed allocation is because some class loaders are |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
753 |
// simply for delegating with no metadata of their own. |
47634
6a0c42c40cd1
8188220: Remove Atomic::*_ptr() uses and overloads from hotspot
coleenp
parents:
47580
diff
changeset
|
754 |
// Lock-free access requires load_acquire. |
49401
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49393
diff
changeset
|
755 |
ClassLoaderMetaspace* metaspace = OrderAccess::load_acquire(&_metaspace); |
38937
2bf3c37c4841
8154750: Add missing OrderAccess operations to ClassLoaderData lock-free data structures
dholmes
parents:
38635
diff
changeset
|
756 |
if (metaspace == NULL) { |
54623
1126f0607c70
8222811: Consolidate MutexLockerEx and MutexLocker
coleenp
parents:
54343
diff
changeset
|
757 |
MutexLocker ml(_metaspace_lock, Mutex::_no_safepoint_check_flag); |
38937
2bf3c37c4841
8154750: Add missing OrderAccess operations to ClassLoaderData lock-free data structures
dholmes
parents:
38635
diff
changeset
|
758 |
// Check if _metaspace got allocated while we were waiting for this lock. |
2bf3c37c4841
8154750: Add missing OrderAccess operations to ClassLoaderData lock-free data structures
dholmes
parents:
38635
diff
changeset
|
759 |
if ((metaspace = _metaspace) == NULL) { |
2bf3c37c4841
8154750: Add missing OrderAccess operations to ClassLoaderData lock-free data structures
dholmes
parents:
38635
diff
changeset
|
760 |
if (this == the_null_class_loader_data()) { |
2bf3c37c4841
8154750: Add missing OrderAccess operations to ClassLoaderData lock-free data structures
dholmes
parents:
38635
diff
changeset
|
761 |
assert (class_loader() == NULL, "Must be"); |
49401
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49393
diff
changeset
|
762 |
metaspace = new ClassLoaderMetaspace(_metaspace_lock, Metaspace::BootMetaspaceType); |
51444
3e5d28e6de32
8209301: JVM rename is_anonymous, host_klass to unsafe specific terminology ahead of Unsafe.defineAnonymousClass deprecation
lfoltan
parents:
51415
diff
changeset
|
763 |
} else if (is_unsafe_anonymous()) { |
3e5d28e6de32
8209301: JVM rename is_anonymous, host_klass to unsafe specific terminology ahead of Unsafe.defineAnonymousClass deprecation
lfoltan
parents:
51415
diff
changeset
|
764 |
metaspace = new ClassLoaderMetaspace(_metaspace_lock, Metaspace::UnsafeAnonymousMetaspaceType); |
38937
2bf3c37c4841
8154750: Add missing OrderAccess operations to ClassLoaderData lock-free data structures
dholmes
parents:
38635
diff
changeset
|
765 |
} else if (class_loader()->is_a(SystemDictionary::reflect_DelegatingClassLoader_klass())) { |
49401
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49393
diff
changeset
|
766 |
metaspace = new ClassLoaderMetaspace(_metaspace_lock, Metaspace::ReflectionMetaspaceType); |
38937
2bf3c37c4841
8154750: Add missing OrderAccess operations to ClassLoaderData lock-free data structures
dholmes
parents:
38635
diff
changeset
|
767 |
} else { |
49401
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49393
diff
changeset
|
768 |
metaspace = new ClassLoaderMetaspace(_metaspace_lock, Metaspace::StandardMetaspaceType); |
15086
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14838
diff
changeset
|
769 |
} |
38937
2bf3c37c4841
8154750: Add missing OrderAccess operations to ClassLoaderData lock-free data structures
dholmes
parents:
38635
diff
changeset
|
770 |
// Ensure _metaspace is stable, since it is examined without a lock |
47634
6a0c42c40cd1
8188220: Remove Atomic::*_ptr() uses and overloads from hotspot
coleenp
parents:
47580
diff
changeset
|
771 |
OrderAccess::release_store(&_metaspace, metaspace); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
772 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
773 |
} |
38937
2bf3c37c4841
8154750: Add missing OrderAccess operations to ClassLoaderData lock-free data structures
dholmes
parents:
38635
diff
changeset
|
774 |
return metaspace; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
775 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
776 |
|
46961
c9094b1e5f87
8186088: ConstantPoolCache::_resolved_references is not a JNIHandle
coleenp
parents:
46746
diff
changeset
|
777 |
OopHandle ClassLoaderData::add_handle(Handle h) { |
54623
1126f0607c70
8222811: Consolidate MutexLockerEx and MutexLocker
coleenp
parents:
54343
diff
changeset
|
778 |
MutexLocker ml(metaspace_lock(), Mutex::_no_safepoint_check_flag); |
47580 | 779 |
record_modified_oops(); |
46961
c9094b1e5f87
8186088: ConstantPoolCache::_resolved_references is not a JNIHandle
coleenp
parents:
46746
diff
changeset
|
780 |
return OopHandle(_handles.add(h())); |
31046
d01ad7a0ecb0
8081320: Backout JDK-8059340: ConstantPool::_resolved_references is missing in heap dump
vlivanov
parents:
31041
diff
changeset
|
781 |
} |
d01ad7a0ecb0
8081320: Backout JDK-8059340: ConstantPool::_resolved_references is missing in heap dump
vlivanov
parents:
31041
diff
changeset
|
782 |
|
47095
9d21da6fe729
8181170: resolved_references array leaks for RedefineClasses
coleenp
parents:
46961
diff
changeset
|
783 |
void ClassLoaderData::remove_handle(OopHandle h) { |
48395 | 784 |
assert(!is_unloading(), "Do not remove a handle for a CLD that is unloading"); |
47095
9d21da6fe729
8181170: resolved_references array leaks for RedefineClasses
coleenp
parents:
46961
diff
changeset
|
785 |
oop* ptr = h.ptr_raw(); |
9d21da6fe729
8181170: resolved_references array leaks for RedefineClasses
coleenp
parents:
46961
diff
changeset
|
786 |
if (ptr != NULL) { |
49403
58fdb6c2a274
8199272: Broken assertion in ClassLoaderData::remove_handle
coleenp
parents:
49401
diff
changeset
|
787 |
assert(_handles.owner_of(ptr), "Got unexpected handle " PTR_FORMAT, p2i(ptr)); |
50803
45c1fde86050
8205559: Remove IN_CONCURRENT_ROOT Access decorator
kbarrett
parents:
50759
diff
changeset
|
788 |
NativeAccess<>::oop_store(ptr, oop(NULL)); |
47095
9d21da6fe729
8181170: resolved_references array leaks for RedefineClasses
coleenp
parents:
46961
diff
changeset
|
789 |
} |
9d21da6fe729
8181170: resolved_references array leaks for RedefineClasses
coleenp
parents:
46961
diff
changeset
|
790 |
} |
9d21da6fe729
8181170: resolved_references array leaks for RedefineClasses
coleenp
parents:
46961
diff
changeset
|
791 |
|
46961
c9094b1e5f87
8186088: ConstantPoolCache::_resolved_references is not a JNIHandle
coleenp
parents:
46746
diff
changeset
|
792 |
void ClassLoaderData::init_handle_locked(OopHandle& dest, Handle h) { |
54623
1126f0607c70
8222811: Consolidate MutexLockerEx and MutexLocker
coleenp
parents:
54343
diff
changeset
|
793 |
MutexLocker ml(metaspace_lock(), Mutex::_no_safepoint_check_flag); |
46961
c9094b1e5f87
8186088: ConstantPoolCache::_resolved_references is not a JNIHandle
coleenp
parents:
46746
diff
changeset
|
794 |
if (dest.resolve() != NULL) { |
c9094b1e5f87
8186088: ConstantPoolCache::_resolved_references is not a JNIHandle
coleenp
parents:
46746
diff
changeset
|
795 |
return; |
c9094b1e5f87
8186088: ConstantPoolCache::_resolved_references is not a JNIHandle
coleenp
parents:
46746
diff
changeset
|
796 |
} else { |
c9094b1e5f87
8186088: ConstantPoolCache::_resolved_references is not a JNIHandle
coleenp
parents:
46746
diff
changeset
|
797 |
dest = _handles.add(h()); |
c9094b1e5f87
8186088: ConstantPoolCache::_resolved_references is not a JNIHandle
coleenp
parents:
46746
diff
changeset
|
798 |
} |
36508 | 799 |
} |
800 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
801 |
// Add this metadata pointer to be freed when it's safe. This is only during |
51338
aa3bfacc912c
8208677: Move inner metaspace cleaning out of class unloading
coleenp
parents:
51334
diff
changeset
|
802 |
// a safepoint which checks if handles point to this metadata field. |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
803 |
void ClassLoaderData::add_to_deallocate_list(Metadata* m) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
804 |
// Metadata in shared region isn't deleted. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
805 |
if (!m->is_shared()) { |
54623
1126f0607c70
8222811: Consolidate MutexLockerEx and MutexLocker
coleenp
parents:
54343
diff
changeset
|
806 |
MutexLocker ml(metaspace_lock(), Mutex::_no_safepoint_check_flag); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
807 |
if (_deallocate_list == NULL) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
808 |
_deallocate_list = new (ResourceObj::C_HEAP, mtClass) GrowableArray<Metadata*>(100, true); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
809 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
810 |
_deallocate_list->append_if_missing(m); |
51338
aa3bfacc912c
8208677: Move inner metaspace cleaning out of class unloading
coleenp
parents:
51334
diff
changeset
|
811 |
log_debug(class, loader, data)("deallocate added for %s", m->print_value_string()); |
aa3bfacc912c
8208677: Move inner metaspace cleaning out of class unloading
coleenp
parents:
51334
diff
changeset
|
812 |
ClassLoaderDataGraph::set_should_clean_deallocate_lists(); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
813 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
814 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
815 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
816 |
// Deallocate free metadata on the free list. How useful the PermGen was! |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
817 |
void ClassLoaderData::free_deallocate_list() { |
52587
6cd56deebb0d
8213092: Add more runtime locks for concurrent class unloading
coleenp
parents:
52141
diff
changeset
|
818 |
// This must be called at a safepoint because it depends on metadata walking at |
6cd56deebb0d
8213092: Add more runtime locks for concurrent class unloading
coleenp
parents:
52141
diff
changeset
|
819 |
// safepoint cleanup time. |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
820 |
assert(SafepointSynchronize::is_at_safepoint(), "only called at safepoint"); |
48395 | 821 |
assert(!is_unloading(), "only called for ClassLoaderData that are not unloading"); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
822 |
if (_deallocate_list == NULL) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
823 |
return; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
824 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
825 |
// Go backwards because this removes entries that are freed. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
826 |
for (int i = _deallocate_list->length() - 1; i >= 0; i--) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
827 |
Metadata* m = _deallocate_list->at(i); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
828 |
if (!m->on_stack()) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
829 |
_deallocate_list->remove_at(i); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
830 |
// There are only three types of metadata that we deallocate directly. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
831 |
// Cast them so they can be used by the template function. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
832 |
if (m->is_method()) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
833 |
MetadataFactory::free_metadata(this, (Method*)m); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
834 |
} else if (m->is_constantPool()) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
835 |
MetadataFactory::free_metadata(this, (ConstantPool*)m); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
836 |
} else if (m->is_klass()) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
837 |
MetadataFactory::free_metadata(this, (InstanceKlass*)m); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
838 |
} else { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
839 |
ShouldNotReachHere(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
840 |
} |
29576
c223b0a9872e
8061205: MetadataOnStackMark only needs to walk code cache during class redefinition
coleenp
parents:
29081
diff
changeset
|
841 |
} else { |
c223b0a9872e
8061205: MetadataOnStackMark only needs to walk code cache during class redefinition
coleenp
parents:
29081
diff
changeset
|
842 |
// Metadata is alive. |
c223b0a9872e
8061205: MetadataOnStackMark only needs to walk code cache during class redefinition
coleenp
parents:
29081
diff
changeset
|
843 |
// If scratch_class is on stack then it shouldn't be on this list! |
c223b0a9872e
8061205: MetadataOnStackMark only needs to walk code cache during class redefinition
coleenp
parents:
29081
diff
changeset
|
844 |
assert(!m->is_klass() || !((InstanceKlass*)m)->is_scratch_class(), |
c223b0a9872e
8061205: MetadataOnStackMark only needs to walk code cache during class redefinition
coleenp
parents:
29081
diff
changeset
|
845 |
"scratch classes on this list should be dead"); |
c223b0a9872e
8061205: MetadataOnStackMark only needs to walk code cache during class redefinition
coleenp
parents:
29081
diff
changeset
|
846 |
// Also should assert that other metadata on the list was found in handles. |
51338
aa3bfacc912c
8208677: Move inner metaspace cleaning out of class unloading
coleenp
parents:
51334
diff
changeset
|
847 |
// Some cleaning remains. |
aa3bfacc912c
8208677: Move inner metaspace cleaning out of class unloading
coleenp
parents:
51334
diff
changeset
|
848 |
ClassLoaderDataGraph::set_should_clean_deallocate_lists(); |
aa3bfacc912c
8208677: Move inner metaspace cleaning out of class unloading
coleenp
parents:
51334
diff
changeset
|
849 |
} |
aa3bfacc912c
8208677: Move inner metaspace cleaning out of class unloading
coleenp
parents:
51334
diff
changeset
|
850 |
} |
aa3bfacc912c
8208677: Move inner metaspace cleaning out of class unloading
coleenp
parents:
51334
diff
changeset
|
851 |
} |
aa3bfacc912c
8208677: Move inner metaspace cleaning out of class unloading
coleenp
parents:
51334
diff
changeset
|
852 |
|
48395 | 853 |
// This is distinct from free_deallocate_list. For class loader data that are |
48405
5f1c30b80554
8193622: JFR test TestUnloadingEventClass.java times out intermittently
coleenp
parents:
48395
diff
changeset
|
854 |
// unloading, this frees the C heap memory for items on the list, and unlinks |
5f1c30b80554
8193622: JFR test TestUnloadingEventClass.java times out intermittently
coleenp
parents:
48395
diff
changeset
|
855 |
// scratch or error classes so that unloading events aren't triggered for these |
5f1c30b80554
8193622: JFR test TestUnloadingEventClass.java times out intermittently
coleenp
parents:
48395
diff
changeset
|
856 |
// classes. The metadata is removed with the unloading metaspace. |
5f1c30b80554
8193622: JFR test TestUnloadingEventClass.java times out intermittently
coleenp
parents:
48395
diff
changeset
|
857 |
// There isn't C heap memory allocated for methods, so nothing is done for them. |
51338
aa3bfacc912c
8208677: Move inner metaspace cleaning out of class unloading
coleenp
parents:
51334
diff
changeset
|
858 |
void ClassLoaderData::free_deallocate_list_C_heap_structures() { |
52587
6cd56deebb0d
8213092: Add more runtime locks for concurrent class unloading
coleenp
parents:
52141
diff
changeset
|
859 |
assert_locked_or_safepoint(ClassLoaderDataGraph_lock); |
48395 | 860 |
assert(is_unloading(), "only called for ClassLoaderData that are unloading"); |
861 |
if (_deallocate_list == NULL) { |
|
862 |
return; |
|
863 |
} |
|
864 |
// Go backwards because this removes entries that are freed. |
|
865 |
for (int i = _deallocate_list->length() - 1; i >= 0; i--) { |
|
866 |
Metadata* m = _deallocate_list->at(i); |
|
867 |
_deallocate_list->remove_at(i); |
|
868 |
if (m->is_constantPool()) { |
|
869 |
((ConstantPool*)m)->release_C_heap_structures(); |
|
48405
5f1c30b80554
8193622: JFR test TestUnloadingEventClass.java times out intermittently
coleenp
parents:
48395
diff
changeset
|
870 |
} else if (m->is_klass()) { |
5f1c30b80554
8193622: JFR test TestUnloadingEventClass.java times out intermittently
coleenp
parents:
48395
diff
changeset
|
871 |
InstanceKlass* ik = (InstanceKlass*)m; |
5f1c30b80554
8193622: JFR test TestUnloadingEventClass.java times out intermittently
coleenp
parents:
48395
diff
changeset
|
872 |
// also releases ik->constants() C heap memory |
5f1c30b80554
8193622: JFR test TestUnloadingEventClass.java times out intermittently
coleenp
parents:
48395
diff
changeset
|
873 |
InstanceKlass::release_C_heap_structures(ik); |
5f1c30b80554
8193622: JFR test TestUnloadingEventClass.java times out intermittently
coleenp
parents:
48395
diff
changeset
|
874 |
// Remove the class so unloading events aren't triggered for |
5f1c30b80554
8193622: JFR test TestUnloadingEventClass.java times out intermittently
coleenp
parents:
48395
diff
changeset
|
875 |
// this class (scratch or error class) in do_unloading(). |
5f1c30b80554
8193622: JFR test TestUnloadingEventClass.java times out intermittently
coleenp
parents:
48395
diff
changeset
|
876 |
remove_class(ik); |
48395 | 877 |
} |
878 |
} |
|
879 |
} |
|
880 |
||
51444
3e5d28e6de32
8209301: JVM rename is_anonymous, host_klass to unsafe specific terminology ahead of Unsafe.defineAnonymousClass deprecation
lfoltan
parents:
51415
diff
changeset
|
881 |
// These CLDs are to contain unsafe anonymous classes used for JSR292 |
3e5d28e6de32
8209301: JVM rename is_anonymous, host_klass to unsafe specific terminology ahead of Unsafe.defineAnonymousClass deprecation
lfoltan
parents:
51415
diff
changeset
|
882 |
ClassLoaderData* ClassLoaderData::unsafe_anonymous_class_loader_data(Handle loader) { |
14588
8ec26d2d9339
8000662: NPG: nashorn ant clean test262 out-of-memory with Java heap
coleenp
parents:
13728
diff
changeset
|
883 |
// Add a new class loader data to the graph. |
49348
fde3feaaa4ed
8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents:
49041
diff
changeset
|
884 |
return ClassLoaderDataGraph::add(loader, true); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
885 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
886 |
|
50634
c349d409262a
8202605: Standardize on ClassLoaderData::loader_name() throughout the VM to obtain a class loader's name
lfoltan
parents:
50599
diff
changeset
|
887 |
// Caller needs ResourceMark |
c349d409262a
8202605: Standardize on ClassLoaderData::loader_name() throughout the VM to obtain a class loader's name
lfoltan
parents:
50599
diff
changeset
|
888 |
// If the class loader's _name has not been explicitly set, the class loader's |
c349d409262a
8202605: Standardize on ClassLoaderData::loader_name() throughout the VM to obtain a class loader's name
lfoltan
parents:
50599
diff
changeset
|
889 |
// qualified class name is returned. |
49348
fde3feaaa4ed
8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents:
49041
diff
changeset
|
890 |
const char* ClassLoaderData::loader_name() const { |
50634
c349d409262a
8202605: Standardize on ClassLoaderData::loader_name() throughout the VM to obtain a class loader's name
lfoltan
parents:
50599
diff
changeset
|
891 |
if (_class_loader_klass == NULL) { |
c349d409262a
8202605: Standardize on ClassLoaderData::loader_name() throughout the VM to obtain a class loader's name
lfoltan
parents:
50599
diff
changeset
|
892 |
return BOOTSTRAP_LOADER_NAME; |
c349d409262a
8202605: Standardize on ClassLoaderData::loader_name() throughout the VM to obtain a class loader's name
lfoltan
parents:
50599
diff
changeset
|
893 |
} else if (_name != NULL) { |
c349d409262a
8202605: Standardize on ClassLoaderData::loader_name() throughout the VM to obtain a class loader's name
lfoltan
parents:
50599
diff
changeset
|
894 |
return _name->as_C_string(); |
c349d409262a
8202605: Standardize on ClassLoaderData::loader_name() throughout the VM to obtain a class loader's name
lfoltan
parents:
50599
diff
changeset
|
895 |
} else { |
c349d409262a
8202605: Standardize on ClassLoaderData::loader_name() throughout the VM to obtain a class loader's name
lfoltan
parents:
50599
diff
changeset
|
896 |
return _class_loader_klass->external_name(); |
c349d409262a
8202605: Standardize on ClassLoaderData::loader_name() throughout the VM to obtain a class loader's name
lfoltan
parents:
50599
diff
changeset
|
897 |
} |
c349d409262a
8202605: Standardize on ClassLoaderData::loader_name() throughout the VM to obtain a class loader's name
lfoltan
parents:
50599
diff
changeset
|
898 |
} |
c349d409262a
8202605: Standardize on ClassLoaderData::loader_name() throughout the VM to obtain a class loader's name
lfoltan
parents:
50599
diff
changeset
|
899 |
|
c349d409262a
8202605: Standardize on ClassLoaderData::loader_name() throughout the VM to obtain a class loader's name
lfoltan
parents:
50599
diff
changeset
|
900 |
// Caller needs ResourceMark |
c349d409262a
8202605: Standardize on ClassLoaderData::loader_name() throughout the VM to obtain a class loader's name
lfoltan
parents:
50599
diff
changeset
|
901 |
// Format of the _name_and_id is as follows: |
c349d409262a
8202605: Standardize on ClassLoaderData::loader_name() throughout the VM to obtain a class loader's name
lfoltan
parents:
50599
diff
changeset
|
902 |
// If the defining loader has a name explicitly set then '<loader-name>' @<id> |
c349d409262a
8202605: Standardize on ClassLoaderData::loader_name() throughout the VM to obtain a class loader's name
lfoltan
parents:
50599
diff
changeset
|
903 |
// If the defining loader has no name then <qualified-class-name> @<id> |
c349d409262a
8202605: Standardize on ClassLoaderData::loader_name() throughout the VM to obtain a class loader's name
lfoltan
parents:
50599
diff
changeset
|
904 |
// If built-in loader, then omit '@<id>' as there is only one instance. |
c349d409262a
8202605: Standardize on ClassLoaderData::loader_name() throughout the VM to obtain a class loader's name
lfoltan
parents:
50599
diff
changeset
|
905 |
const char* ClassLoaderData::loader_name_and_id() const { |
c349d409262a
8202605: Standardize on ClassLoaderData::loader_name() throughout the VM to obtain a class loader's name
lfoltan
parents:
50599
diff
changeset
|
906 |
if (_class_loader_klass == NULL) { |
c349d409262a
8202605: Standardize on ClassLoaderData::loader_name() throughout the VM to obtain a class loader's name
lfoltan
parents:
50599
diff
changeset
|
907 |
return "'" BOOTSTRAP_LOADER_NAME "'"; |
50759
00c4edaf2017
8205509: assert(_name_and_id != 0LL) failed: encountered a class loader null name and id
lfoltan
parents:
50634
diff
changeset
|
908 |
} else if (_name_and_id != NULL) { |
00c4edaf2017
8205509: assert(_name_and_id != 0LL) failed: encountered a class loader null name and id
lfoltan
parents:
50634
diff
changeset
|
909 |
return _name_and_id->as_C_string(); |
49824
e242740a92b8
8201556: Disallow reading oops in ClassLoaderData if unloading
coleenp
parents:
49818
diff
changeset
|
910 |
} else { |
50759
00c4edaf2017
8205509: assert(_name_and_id != 0LL) failed: encountered a class loader null name and id
lfoltan
parents:
50634
diff
changeset
|
911 |
// May be called in a race before _name_and_id is initialized. |
00c4edaf2017
8205509: assert(_name_and_id != 0LL) failed: encountered a class loader null name and id
lfoltan
parents:
50634
diff
changeset
|
912 |
return _class_loader_klass->external_name(); |
49824
e242740a92b8
8201556: Disallow reading oops in ClassLoaderData if unloading
coleenp
parents:
49818
diff
changeset
|
913 |
} |
14588
8ec26d2d9339
8000662: NPG: nashorn ant clean test262 out-of-memory with Java heap
coleenp
parents:
13728
diff
changeset
|
914 |
} |
8ec26d2d9339
8000662: NPG: nashorn ant clean test262 out-of-memory with Java heap
coleenp
parents:
13728
diff
changeset
|
915 |
|
49348
fde3feaaa4ed
8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents:
49041
diff
changeset
|
916 |
void ClassLoaderData::print_value_on(outputStream* out) const { |
49824
e242740a92b8
8201556: Disallow reading oops in ClassLoaderData if unloading
coleenp
parents:
49818
diff
changeset
|
917 |
if (!is_unloading() && class_loader() != NULL) { |
49348
fde3feaaa4ed
8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents:
49041
diff
changeset
|
918 |
out->print("loader data: " INTPTR_FORMAT " for instance ", p2i(this)); |
50634
c349d409262a
8202605: Standardize on ClassLoaderData::loader_name() throughout the VM to obtain a class loader's name
lfoltan
parents:
50599
diff
changeset
|
919 |
class_loader()->print_value_on(out); // includes loader_name_and_id() and address of class loader instance |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
920 |
} else { |
50634
c349d409262a
8202605: Standardize on ClassLoaderData::loader_name() throughout the VM to obtain a class loader's name
lfoltan
parents:
50599
diff
changeset
|
921 |
// loader data: 0xsomeaddr of 'bootstrap' |
c349d409262a
8202605: Standardize on ClassLoaderData::loader_name() throughout the VM to obtain a class loader's name
lfoltan
parents:
50599
diff
changeset
|
922 |
out->print("loader data: " INTPTR_FORMAT " of %s", p2i(this), loader_name_and_id()); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
923 |
} |
51444
3e5d28e6de32
8209301: JVM rename is_anonymous, host_klass to unsafe specific terminology ahead of Unsafe.defineAnonymousClass deprecation
lfoltan
parents:
51415
diff
changeset
|
924 |
if (is_unsafe_anonymous()) { |
3e5d28e6de32
8209301: JVM rename is_anonymous, host_klass to unsafe specific terminology ahead of Unsafe.defineAnonymousClass deprecation
lfoltan
parents:
51415
diff
changeset
|
925 |
out->print(" unsafe anonymous"); |
49348
fde3feaaa4ed
8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents:
49041
diff
changeset
|
926 |
} |
fde3feaaa4ed
8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents:
49041
diff
changeset
|
927 |
} |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
928 |
|
54807 | 929 |
void ClassLoaderData::print_value() const { print_value_on(tty); } |
930 |
||
49348
fde3feaaa4ed
8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents:
49041
diff
changeset
|
931 |
#ifndef PRODUCT |
fde3feaaa4ed
8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents:
49041
diff
changeset
|
932 |
void ClassLoaderData::print_on(outputStream* out) const { |
fde3feaaa4ed
8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents:
49041
diff
changeset
|
933 |
out->print("ClassLoaderData CLD: " PTR_FORMAT ", loader: " PTR_FORMAT ", loader_klass: %s {", |
50634
c349d409262a
8202605: Standardize on ClassLoaderData::loader_name() throughout the VM to obtain a class loader's name
lfoltan
parents:
50599
diff
changeset
|
934 |
p2i(this), p2i(_class_loader.ptr_raw()), loader_name_and_id()); |
51444
3e5d28e6de32
8209301: JVM rename is_anonymous, host_klass to unsafe specific terminology ahead of Unsafe.defineAnonymousClass deprecation
lfoltan
parents:
51415
diff
changeset
|
935 |
if (is_unsafe_anonymous()) out->print(" unsafe anonymous"); |
49348
fde3feaaa4ed
8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents:
49041
diff
changeset
|
936 |
if (claimed()) out->print(" claimed"); |
fde3feaaa4ed
8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents:
49041
diff
changeset
|
937 |
if (is_unloading()) out->print(" unloading"); |
fde3feaaa4ed
8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents:
49041
diff
changeset
|
938 |
out->print(" metaspace: " INTPTR_FORMAT, p2i(metaspace_or_null())); |
fde3feaaa4ed
8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents:
49041
diff
changeset
|
939 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
940 |
if (_jmethod_ids != NULL) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
941 |
Method::print_jmethod_ids(this, out); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
942 |
} |
49348
fde3feaaa4ed
8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents:
49041
diff
changeset
|
943 |
out->print(" handles count %d", _handles.count()); |
fde3feaaa4ed
8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents:
49041
diff
changeset
|
944 |
out->print(" dependencies %d", _dependency_count); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
945 |
out->print_cr("}"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
946 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
947 |
#endif // PRODUCT |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
948 |
|
54807 | 949 |
void ClassLoaderData::print() const { print_on(tty); } |
950 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
951 |
void ClassLoaderData::verify() { |
38937
2bf3c37c4841
8154750: Add missing OrderAccess operations to ClassLoaderData lock-free data structures
dholmes
parents:
38635
diff
changeset
|
952 |
assert_locked_or_safepoint(_metaspace_lock); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
953 |
oop cl = class_loader(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
954 |
|
51444
3e5d28e6de32
8209301: JVM rename is_anonymous, host_klass to unsafe specific terminology ahead of Unsafe.defineAnonymousClass deprecation
lfoltan
parents:
51415
diff
changeset
|
955 |
guarantee(this == class_loader_data(cl) || is_unsafe_anonymous(), "Must be the same"); |
3e5d28e6de32
8209301: JVM rename is_anonymous, host_klass to unsafe specific terminology ahead of Unsafe.defineAnonymousClass deprecation
lfoltan
parents:
51415
diff
changeset
|
956 |
guarantee(cl != NULL || this == ClassLoaderData::the_null_class_loader_data() || is_unsafe_anonymous(), "must be"); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
957 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
958 |
// Verify the integrity of the allocated space. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
959 |
if (metaspace_or_null() != NULL) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
960 |
metaspace_or_null()->verify(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
961 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
962 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
963 |
for (Klass* k = _klasses; k != NULL; k = k->next_link()) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
964 |
guarantee(k->class_loader_data() == this, "Must be the same"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
965 |
k->verify(); |
16352
1ff72c6eaa70
8007725: NPG: Klass::restore_unshareable_info() triggers assert(k->java_mirror() == NULL)
coleenp
parents:
15437
diff
changeset
|
966 |
assert(k != k->next_link(), "no loops!"); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
967 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
968 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
969 |
|
22794
f1c014ad3754
8027146: Class loading verification failure if GC occurs in Universe::flush_dependents_on
coleenp
parents:
22201
diff
changeset
|
970 |
bool ClassLoaderData::contains_klass(Klass* klass) { |
47634
6a0c42c40cd1
8188220: Remove Atomic::*_ptr() uses and overloads from hotspot
coleenp
parents:
47580
diff
changeset
|
971 |
// Lock-free access requires load_acquire |
6a0c42c40cd1
8188220: Remove Atomic::*_ptr() uses and overloads from hotspot
coleenp
parents:
47580
diff
changeset
|
972 |
for (Klass* k = OrderAccess::load_acquire(&_klasses); k != NULL; k = k->next_link()) { |
22794
f1c014ad3754
8027146: Class loading verification failure if GC occurs in Universe::flush_dependents_on
coleenp
parents:
22201
diff
changeset
|
973 |
if (k == klass) return true; |
f1c014ad3754
8027146: Class loading verification failure if GC occurs in Universe::flush_dependents_on
coleenp
parents:
22201
diff
changeset
|
974 |
} |
f1c014ad3754
8027146: Class loading verification failure if GC occurs in Universe::flush_dependents_on
coleenp
parents:
22201
diff
changeset
|
975 |
return false; |
f1c014ad3754
8027146: Class loading verification failure if GC occurs in Universe::flush_dependents_on
coleenp
parents:
22201
diff
changeset
|
976 |
} |