author | hseigel |
Mon, 05 Mar 2018 10:29:23 -0500 | |
changeset 49340 | 4e82736053ae |
parent 49329 | 04ed29f9ef33 |
child 49348 | fde3feaaa4ed |
permissions | -rw-r--r-- |
1 | 1 |
/* |
48781
6ebef5cd0c8d
8194736: Refactor weak oops in ProtectionDomain table to use the Access API
eosterlund
parents:
47774
diff
changeset
|
2 |
* Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. |
1 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5426
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5426
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5426
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#include "precompiled.hpp" |
35498
392b50de06c6
8146401: Clean up oop.hpp: add inline directives and fix header files
goetz
parents:
34257
diff
changeset
|
26 |
#include "classfile/classLoaderData.inline.hpp" |
34257
4be3504cc03b
8140802: Clean up and refactor of class loading code for CDS
iklam
parents:
33611
diff
changeset
|
27 |
#include "classfile/sharedClassUtil.hpp" |
49340
4e82736053ae
8191102: Incorrect include file use in classLoader.hpp
hseigel
parents:
49329
diff
changeset
|
28 |
#include "classfile/dictionary.inline.hpp" |
46382
5520c435279b
8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents:
46380
diff
changeset
|
29 |
#include "classfile/protectionDomainCache.hpp" |
7397 | 30 |
#include "classfile/systemDictionary.hpp" |
34257
4be3504cc03b
8140802: Clean up and refactor of class loading code for CDS
iklam
parents:
33611
diff
changeset
|
31 |
#include "classfile/systemDictionaryShared.hpp" |
47774 | 32 |
#include "gc/shared/gcLocker.hpp" |
46701
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46475
diff
changeset
|
33 |
#include "logging/log.hpp" |
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46475
diff
changeset
|
34 |
#include "logging/logStream.hpp" |
20405 | 35 |
#include "memory/iterator.hpp" |
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
36 |
#include "memory/metaspaceClosure.hpp" |
37248 | 37 |
#include "memory/resourceArea.hpp" |
7397 | 38 |
#include "oops/oop.inline.hpp" |
46729 | 39 |
#include "runtime/atomic.hpp" |
24351
61b33cc6d3cf
8042195: Introduce umbrella header orderAccess.inline.hpp.
goetz
parents:
22794
diff
changeset
|
40 |
#include "runtime/orderAccess.inline.hpp" |
7397 | 41 |
#include "utilities/hashtable.inline.hpp" |
1 | 42 |
|
47774 | 43 |
// Optimization: if any dictionary needs resizing, we set this flag, |
44 |
// so that we dont't have to walk all dictionaries to check if any actually |
|
45 |
// needs resizing, which is costly to do at Safepoint. |
|
46 |
bool Dictionary::_some_dictionary_needs_resizing = false; |
|
47 |
||
34257
4be3504cc03b
8140802: Clean up and refactor of class loading code for CDS
iklam
parents:
33611
diff
changeset
|
48 |
size_t Dictionary::entry_size() { |
4be3504cc03b
8140802: Clean up and refactor of class loading code for CDS
iklam
parents:
33611
diff
changeset
|
49 |
if (DumpSharedSpaces) { |
4be3504cc03b
8140802: Clean up and refactor of class loading code for CDS
iklam
parents:
33611
diff
changeset
|
50 |
return SystemDictionaryShared::dictionary_entry_size(); |
4be3504cc03b
8140802: Clean up and refactor of class loading code for CDS
iklam
parents:
33611
diff
changeset
|
51 |
} else { |
4be3504cc03b
8140802: Clean up and refactor of class loading code for CDS
iklam
parents:
33611
diff
changeset
|
52 |
return sizeof(DictionaryEntry); |
4be3504cc03b
8140802: Clean up and refactor of class loading code for CDS
iklam
parents:
33611
diff
changeset
|
53 |
} |
4be3504cc03b
8140802: Clean up and refactor of class loading code for CDS
iklam
parents:
33611
diff
changeset
|
54 |
} |
1 | 55 |
|
47774 | 56 |
Dictionary::Dictionary(ClassLoaderData* loader_data, int table_size, bool resizable) |
57 |
: _loader_data(loader_data), _resizable(resizable), _needs_resizing(false), |
|
58 |
Hashtable<InstanceKlass*, mtClass>(table_size, (int)entry_size()) { |
|
1 | 59 |
}; |
60 |
||
61 |
||
46729 | 62 |
Dictionary::Dictionary(ClassLoaderData* loader_data, |
63 |
int table_size, HashtableBucket<mtClass>* t, |
|
47774 | 64 |
int number_of_entries, bool resizable) |
65 |
: _loader_data(loader_data), _resizable(resizable), _needs_resizing(false), |
|
66 |
Hashtable<InstanceKlass*, mtClass>(table_size, (int)entry_size(), t, number_of_entries) { |
|
1 | 67 |
}; |
68 |
||
46729 | 69 |
Dictionary::~Dictionary() { |
70 |
DictionaryEntry* probe = NULL; |
|
71 |
for (int index = 0; index < table_size(); index++) { |
|
72 |
for (DictionaryEntry** p = bucket_addr(index); *p != NULL; ) { |
|
73 |
probe = *p; |
|
74 |
*p = probe->next(); |
|
75 |
free_entry(probe); |
|
76 |
} |
|
77 |
} |
|
78 |
assert(number_of_entries() == 0, "should have removed all entries"); |
|
79 |
assert(new_entry_free_list() == NULL, "entry present on Dictionary's free list"); |
|
80 |
free_buckets(); |
|
20405 | 81 |
} |
1 | 82 |
|
46729 | 83 |
DictionaryEntry* Dictionary::new_entry(unsigned int hash, InstanceKlass* klass) { |
84 |
DictionaryEntry* entry = (DictionaryEntry*)Hashtable<InstanceKlass*, mtClass>::allocate_new_entry(hash, klass); |
|
1 | 85 |
entry->set_pd_set(NULL); |
33611
9abd65805e19
8139203: Consistent naming for klass type predicates
coleenp
parents:
33602
diff
changeset
|
86 |
assert(klass->is_instance_klass(), "Must be"); |
34257
4be3504cc03b
8140802: Clean up and refactor of class loading code for CDS
iklam
parents:
33611
diff
changeset
|
87 |
if (DumpSharedSpaces) { |
4be3504cc03b
8140802: Clean up and refactor of class loading code for CDS
iklam
parents:
33611
diff
changeset
|
88 |
SystemDictionaryShared::init_shared_dictionary_entry(klass, entry); |
4be3504cc03b
8140802: Clean up and refactor of class loading code for CDS
iklam
parents:
33611
diff
changeset
|
89 |
} |
1 | 90 |
return entry; |
91 |
} |
|
92 |
||
93 |
||
94 |
void Dictionary::free_entry(DictionaryEntry* entry) { |
|
95 |
// avoid recursion when deleting linked list |
|
47098
e704f55561c3
8164207: Checking missing load-acquire in relation to _pd_set in dictionary.cpp
coleenp
parents:
46746
diff
changeset
|
96 |
// pd_set is accessed during a safepoint. |
1 | 97 |
while (entry->pd_set() != NULL) { |
98 |
ProtectionDomainEntry* to_delete = entry->pd_set(); |
|
99 |
entry->set_pd_set(to_delete->next()); |
|
100 |
delete to_delete; |
|
101 |
} |
|
46729 | 102 |
// Unlink from the Hashtable prior to freeing |
103 |
unlink_entry(entry); |
|
104 |
FREE_C_HEAP_ARRAY(char, entry); |
|
1 | 105 |
} |
106 |
||
47774 | 107 |
const int _resize_load_trigger = 5; // load factor that will trigger the resize |
108 |
const double _resize_factor = 2.0; // by how much we will resize using current number of entries |
|
109 |
const int _resize_max_size = 40423; // the max dictionary size allowed |
|
110 |
const int _primelist[] = {107, 1009, 2017, 4049, 5051, 10103, 20201, _resize_max_size}; |
|
111 |
const int _prime_array_size = sizeof(_primelist)/sizeof(int); |
|
112 |
||
113 |
// Calculate next "good" dictionary size based on requested count |
|
114 |
static int calculate_dictionary_size(int requested) { |
|
115 |
int newsize = _primelist[0]; |
|
116 |
int index = 0; |
|
117 |
for (newsize = _primelist[index]; index < (_prime_array_size - 1); |
|
118 |
newsize = _primelist[++index]) { |
|
119 |
if (requested <= newsize) { |
|
120 |
break; |
|
121 |
} |
|
122 |
} |
|
123 |
return newsize; |
|
124 |
} |
|
125 |
||
126 |
bool Dictionary::does_any_dictionary_needs_resizing() { |
|
127 |
return Dictionary::_some_dictionary_needs_resizing; |
|
128 |
} |
|
129 |
||
130 |
void Dictionary::check_if_needs_resize() { |
|
131 |
if (_resizable == true) { |
|
132 |
if (number_of_entries() > (_resize_load_trigger*table_size())) { |
|
133 |
_needs_resizing = true; |
|
134 |
Dictionary::_some_dictionary_needs_resizing = true; |
|
135 |
} |
|
136 |
} |
|
137 |
} |
|
138 |
||
139 |
bool Dictionary::resize_if_needed() { |
|
140 |
int desired_size = 0; |
|
141 |
if (_needs_resizing == true) { |
|
142 |
desired_size = calculate_dictionary_size((int)(_resize_factor*number_of_entries())); |
|
143 |
if (desired_size >= _resize_max_size) { |
|
144 |
desired_size = _resize_max_size; |
|
145 |
// We have reached the limit, turn resizing off |
|
146 |
_resizable = false; |
|
147 |
} |
|
148 |
if ((desired_size != 0) && (desired_size != table_size())) { |
|
149 |
if (!resize(desired_size)) { |
|
150 |
// Something went wrong, turn resizing off |
|
151 |
_resizable = false; |
|
152 |
} |
|
153 |
} |
|
154 |
} |
|
155 |
||
156 |
_needs_resizing = false; |
|
157 |
Dictionary::_some_dictionary_needs_resizing = false; |
|
158 |
||
159 |
return (desired_size != 0); |
|
160 |
} |
|
1 | 161 |
|
162 |
bool DictionaryEntry::contains_protection_domain(oop protection_domain) const { |
|
163 |
#ifdef ASSERT |
|
46729 | 164 |
if (protection_domain == instance_klass()->protection_domain()) { |
1 | 165 |
// Ensure this doesn't show up in the pd_set (invariant) |
166 |
bool in_pd_set = false; |
|
47098
e704f55561c3
8164207: Checking missing load-acquire in relation to _pd_set in dictionary.cpp
coleenp
parents:
46746
diff
changeset
|
167 |
for (ProtectionDomainEntry* current = pd_set_acquire(); |
1 | 168 |
current != NULL; |
169 |
current = current->next()) { |
|
48781
6ebef5cd0c8d
8194736: Refactor weak oops in ProtectionDomain table to use the Access API
eosterlund
parents:
47774
diff
changeset
|
170 |
if (current->object_no_keepalive() == protection_domain) { |
1 | 171 |
in_pd_set = true; |
172 |
break; |
|
173 |
} |
|
174 |
} |
|
175 |
if (in_pd_set) { |
|
176 |
assert(false, "A klass's protection domain should not show up " |
|
177 |
"in its sys. dict. PD set"); |
|
178 |
} |
|
179 |
} |
|
180 |
#endif /* ASSERT */ |
|
181 |
||
46729 | 182 |
if (protection_domain == instance_klass()->protection_domain()) { |
1 | 183 |
// Succeeds trivially |
184 |
return true; |
|
185 |
} |
|
186 |
||
47098
e704f55561c3
8164207: Checking missing load-acquire in relation to _pd_set in dictionary.cpp
coleenp
parents:
46746
diff
changeset
|
187 |
for (ProtectionDomainEntry* current = pd_set_acquire(); |
1 | 188 |
current != NULL; |
189 |
current = current->next()) { |
|
48781
6ebef5cd0c8d
8194736: Refactor weak oops in ProtectionDomain table to use the Access API
eosterlund
parents:
47774
diff
changeset
|
190 |
if (current->object_no_keepalive() == protection_domain) return true; |
1 | 191 |
} |
192 |
return false; |
|
193 |
} |
|
194 |
||
195 |
||
46274
534d019edb92
8175104: Unhandled oop in ProtectionDomainCacheTable::compute_hash
coleenp
parents:
46271
diff
changeset
|
196 |
void DictionaryEntry::add_protection_domain(Dictionary* dict, Handle protection_domain) { |
1 | 197 |
assert_locked_or_safepoint(SystemDictionary_lock); |
46274
534d019edb92
8175104: Unhandled oop in ProtectionDomainCacheTable::compute_hash
coleenp
parents:
46271
diff
changeset
|
198 |
if (!contains_protection_domain(protection_domain())) { |
46729 | 199 |
ProtectionDomainCacheEntry* entry = SystemDictionary::cache_get(protection_domain); |
1 | 200 |
ProtectionDomainEntry* new_head = |
47098
e704f55561c3
8164207: Checking missing load-acquire in relation to _pd_set in dictionary.cpp
coleenp
parents:
46746
diff
changeset
|
201 |
new ProtectionDomainEntry(entry, pd_set()); |
1 | 202 |
// Warning: Preserve store ordering. The SystemDictionary is read |
203 |
// without locks. The new ProtectionDomainEntry must be |
|
204 |
// complete before other threads can be allowed to see it |
|
205 |
// via a store to _pd_set. |
|
47098
e704f55561c3
8164207: Checking missing load-acquire in relation to _pd_set in dictionary.cpp
coleenp
parents:
46746
diff
changeset
|
206 |
release_set_pd_set(new_head); |
1 | 207 |
} |
46701
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46475
diff
changeset
|
208 |
LogTarget(Trace, protectiondomain) lt; |
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46475
diff
changeset
|
209 |
if (lt.is_enabled()) { |
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46475
diff
changeset
|
210 |
LogStream ls(lt); |
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46475
diff
changeset
|
211 |
print_count(&ls); |
1 | 212 |
} |
213 |
} |
|
214 |
||
48811
58787a1708d2
8175249: VMThread::run fails in VerifyBeforeExit : Universe::verify
coleenp
parents:
48781
diff
changeset
|
215 |
// During class loading we may have cached a protection domain that has |
58787a1708d2
8175249: VMThread::run fails in VerifyBeforeExit : Universe::verify
coleenp
parents:
48781
diff
changeset
|
216 |
// since been unreferenced, so this entry should be cleared. |
58787a1708d2
8175249: VMThread::run fails in VerifyBeforeExit : Universe::verify
coleenp
parents:
48781
diff
changeset
|
217 |
void Dictionary::clean_cached_protection_domains(BoolObjectClosure* is_alive, DictionaryEntry* probe) { |
58787a1708d2
8175249: VMThread::run fails in VerifyBeforeExit : Universe::verify
coleenp
parents:
48781
diff
changeset
|
218 |
assert_locked_or_safepoint(SystemDictionary_lock); |
1 | 219 |
|
48811
58787a1708d2
8175249: VMThread::run fails in VerifyBeforeExit : Universe::verify
coleenp
parents:
48781
diff
changeset
|
220 |
ProtectionDomainEntry* current = probe->pd_set(); |
58787a1708d2
8175249: VMThread::run fails in VerifyBeforeExit : Universe::verify
coleenp
parents:
48781
diff
changeset
|
221 |
ProtectionDomainEntry* prev = NULL; |
58787a1708d2
8175249: VMThread::run fails in VerifyBeforeExit : Universe::verify
coleenp
parents:
48781
diff
changeset
|
222 |
while (current != NULL) { |
58787a1708d2
8175249: VMThread::run fails in VerifyBeforeExit : Universe::verify
coleenp
parents:
48781
diff
changeset
|
223 |
if (!is_alive->do_object_b(current->object_no_keepalive())) { |
58787a1708d2
8175249: VMThread::run fails in VerifyBeforeExit : Universe::verify
coleenp
parents:
48781
diff
changeset
|
224 |
LogTarget(Debug, protectiondomain) lt; |
58787a1708d2
8175249: VMThread::run fails in VerifyBeforeExit : Universe::verify
coleenp
parents:
48781
diff
changeset
|
225 |
if (lt.is_enabled()) { |
58787a1708d2
8175249: VMThread::run fails in VerifyBeforeExit : Universe::verify
coleenp
parents:
48781
diff
changeset
|
226 |
ResourceMark rm; |
58787a1708d2
8175249: VMThread::run fails in VerifyBeforeExit : Universe::verify
coleenp
parents:
48781
diff
changeset
|
227 |
// Print out trace information |
58787a1708d2
8175249: VMThread::run fails in VerifyBeforeExit : Universe::verify
coleenp
parents:
48781
diff
changeset
|
228 |
LogStream ls(lt); |
58787a1708d2
8175249: VMThread::run fails in VerifyBeforeExit : Universe::verify
coleenp
parents:
48781
diff
changeset
|
229 |
ls.print_cr("PD in set is not alive:"); |
58787a1708d2
8175249: VMThread::run fails in VerifyBeforeExit : Universe::verify
coleenp
parents:
48781
diff
changeset
|
230 |
ls.print("class loader: "); loader_data()->class_loader()->print_value_on(&ls); |
58787a1708d2
8175249: VMThread::run fails in VerifyBeforeExit : Universe::verify
coleenp
parents:
48781
diff
changeset
|
231 |
ls.print(" protection domain: "); current->object_no_keepalive()->print_value_on(&ls); |
58787a1708d2
8175249: VMThread::run fails in VerifyBeforeExit : Universe::verify
coleenp
parents:
48781
diff
changeset
|
232 |
ls.print(" loading: "); probe->instance_klass()->print_value_on(&ls); |
58787a1708d2
8175249: VMThread::run fails in VerifyBeforeExit : Universe::verify
coleenp
parents:
48781
diff
changeset
|
233 |
ls.cr(); |
58787a1708d2
8175249: VMThread::run fails in VerifyBeforeExit : Universe::verify
coleenp
parents:
48781
diff
changeset
|
234 |
} |
58787a1708d2
8175249: VMThread::run fails in VerifyBeforeExit : Universe::verify
coleenp
parents:
48781
diff
changeset
|
235 |
if (probe->pd_set() == current) { |
58787a1708d2
8175249: VMThread::run fails in VerifyBeforeExit : Universe::verify
coleenp
parents:
48781
diff
changeset
|
236 |
probe->set_pd_set(current->next()); |
58787a1708d2
8175249: VMThread::run fails in VerifyBeforeExit : Universe::verify
coleenp
parents:
48781
diff
changeset
|
237 |
} else { |
58787a1708d2
8175249: VMThread::run fails in VerifyBeforeExit : Universe::verify
coleenp
parents:
48781
diff
changeset
|
238 |
assert(prev != NULL, "should be set by alive entry"); |
58787a1708d2
8175249: VMThread::run fails in VerifyBeforeExit : Universe::verify
coleenp
parents:
48781
diff
changeset
|
239 |
prev->set_next(current->next()); |
58787a1708d2
8175249: VMThread::run fails in VerifyBeforeExit : Universe::verify
coleenp
parents:
48781
diff
changeset
|
240 |
} |
58787a1708d2
8175249: VMThread::run fails in VerifyBeforeExit : Universe::verify
coleenp
parents:
48781
diff
changeset
|
241 |
ProtectionDomainEntry* to_delete = current; |
58787a1708d2
8175249: VMThread::run fails in VerifyBeforeExit : Universe::verify
coleenp
parents:
48781
diff
changeset
|
242 |
current = current->next(); |
58787a1708d2
8175249: VMThread::run fails in VerifyBeforeExit : Universe::verify
coleenp
parents:
48781
diff
changeset
|
243 |
delete to_delete; |
58787a1708d2
8175249: VMThread::run fails in VerifyBeforeExit : Universe::verify
coleenp
parents:
48781
diff
changeset
|
244 |
} else { |
58787a1708d2
8175249: VMThread::run fails in VerifyBeforeExit : Universe::verify
coleenp
parents:
48781
diff
changeset
|
245 |
prev = current; |
58787a1708d2
8175249: VMThread::run fails in VerifyBeforeExit : Universe::verify
coleenp
parents:
48781
diff
changeset
|
246 |
current = current->next(); |
58787a1708d2
8175249: VMThread::run fails in VerifyBeforeExit : Universe::verify
coleenp
parents:
48781
diff
changeset
|
247 |
} |
58787a1708d2
8175249: VMThread::run fails in VerifyBeforeExit : Universe::verify
coleenp
parents:
48781
diff
changeset
|
248 |
} |
58787a1708d2
8175249: VMThread::run fails in VerifyBeforeExit : Universe::verify
coleenp
parents:
48781
diff
changeset
|
249 |
} |
58787a1708d2
8175249: VMThread::run fails in VerifyBeforeExit : Universe::verify
coleenp
parents:
48781
diff
changeset
|
250 |
|
58787a1708d2
8175249: VMThread::run fails in VerifyBeforeExit : Universe::verify
coleenp
parents:
48781
diff
changeset
|
251 |
|
58787a1708d2
8175249: VMThread::run fails in VerifyBeforeExit : Universe::verify
coleenp
parents:
48781
diff
changeset
|
252 |
void Dictionary::do_unloading(BoolObjectClosure* is_alive) { |
5402
c51fd0c1d005
6888953: some calls to function-like macros are missing semicolons
jcoomes
parents:
2534
diff
changeset
|
253 |
assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint"); |
1 | 254 |
|
46729 | 255 |
// The NULL class loader doesn't initiate loading classes from other class loaders |
256 |
if (loader_data() == ClassLoaderData::the_null_class_loader_data()) { |
|
257 |
return; |
|
258 |
} |
|
259 |
||
260 |
// Remove unloaded entries and classes from this dictionary |
|
1 | 261 |
DictionaryEntry* probe = NULL; |
26174
ca46a107cb78
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
25492
diff
changeset
|
262 |
for (int index = 0; index < table_size(); index++) { |
1 | 263 |
for (DictionaryEntry** p = bucket_addr(index); *p != NULL; ) { |
264 |
probe = *p; |
|
46729 | 265 |
InstanceKlass* ik = probe->instance_klass(); |
266 |
ClassLoaderData* k_def_class_loader_data = ik->class_loader_data(); |
|
1 | 267 |
|
46729 | 268 |
// If the klass that this loader initiated is dead, |
269 |
// (determined by checking the defining class loader) |
|
270 |
// remove this entry. |
|
271 |
if (k_def_class_loader_data->is_unloading()) { |
|
272 |
assert(k_def_class_loader_data != loader_data(), |
|
273 |
"cannot have live defining loader and unreachable klass"); |
|
274 |
*p = probe->next(); |
|
275 |
free_entry(probe); |
|
276 |
continue; |
|
1 | 277 |
} |
48811
58787a1708d2
8175249: VMThread::run fails in VerifyBeforeExit : Universe::verify
coleenp
parents:
48781
diff
changeset
|
278 |
// Clean pd_set |
58787a1708d2
8175249: VMThread::run fails in VerifyBeforeExit : Universe::verify
coleenp
parents:
48781
diff
changeset
|
279 |
clean_cached_protection_domains(is_alive, probe); |
1 | 280 |
p = probe->next_addr(); |
281 |
} |
|
282 |
} |
|
283 |
} |
|
284 |
||
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25492
diff
changeset
|
285 |
void Dictionary::remove_classes_in_error_state() { |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25492
diff
changeset
|
286 |
assert(DumpSharedSpaces, "supported only when dumping"); |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25492
diff
changeset
|
287 |
DictionaryEntry* probe = NULL; |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25492
diff
changeset
|
288 |
for (int index = 0; index < table_size(); index++) { |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25492
diff
changeset
|
289 |
for (DictionaryEntry** p = bucket_addr(index); *p != NULL; ) { |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25492
diff
changeset
|
290 |
probe = *p; |
46729 | 291 |
InstanceKlass* ik = probe->instance_klass(); |
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25492
diff
changeset
|
292 |
if (ik->is_in_error_state()) { // purge this entry |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25492
diff
changeset
|
293 |
*p = probe->next(); |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25492
diff
changeset
|
294 |
free_entry(probe); |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25492
diff
changeset
|
295 |
ResourceMark rm; |
27618
790a8bf5488b
8064375: Change certain errors to warnings in CDS output.
jiangli
parents:
26181
diff
changeset
|
296 |
tty->print_cr("Preload Warning: Removed error class: %s", ik->external_name()); |
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25492
diff
changeset
|
297 |
continue; |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25492
diff
changeset
|
298 |
} |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25492
diff
changeset
|
299 |
|
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25492
diff
changeset
|
300 |
p = probe->next_addr(); |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25492
diff
changeset
|
301 |
} |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25492
diff
changeset
|
302 |
} |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25492
diff
changeset
|
303 |
} |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25492
diff
changeset
|
304 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
305 |
// Just the classes from defining class loaders |
46729 | 306 |
void Dictionary::classes_do(void f(InstanceKlass*)) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
307 |
for (int index = 0; index < table_size(); index++) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
308 |
for (DictionaryEntry* probe = bucket(index); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
309 |
probe != NULL; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
310 |
probe = probe->next()) { |
46729 | 311 |
InstanceKlass* k = probe->instance_klass(); |
312 |
if (loader_data() == k->class_loader_data()) { |
|
1 | 313 |
f(k); |
314 |
} |
|
315 |
} |
|
316 |
} |
|
317 |
} |
|
318 |
||
319 |
// Added for initialize_itable_for_klass to handle exceptions |
|
320 |
// Just the classes from defining class loaders |
|
46729 | 321 |
void Dictionary::classes_do(void f(InstanceKlass*, TRAPS), TRAPS) { |
1 | 322 |
for (int index = 0; index < table_size(); index++) { |
323 |
for (DictionaryEntry* probe = bucket(index); |
|
324 |
probe != NULL; |
|
325 |
probe = probe->next()) { |
|
46729 | 326 |
InstanceKlass* k = probe->instance_klass(); |
327 |
if (loader_data() == k->class_loader_data()) { |
|
1 | 328 |
f(k, CHECK); |
329 |
} |
|
330 |
} |
|
331 |
} |
|
332 |
} |
|
333 |
||
46729 | 334 |
// All classes, and their class loaders, including initiating class loaders |
335 |
void Dictionary::all_entries_do(void f(InstanceKlass*, ClassLoaderData*)) { |
|
1 | 336 |
for (int index = 0; index < table_size(); index++) { |
337 |
for (DictionaryEntry* probe = bucket(index); |
|
338 |
probe != NULL; |
|
339 |
probe = probe->next()) { |
|
46729 | 340 |
InstanceKlass* k = probe->instance_klass(); |
341 |
f(k, loader_data()); |
|
1 | 342 |
} |
343 |
} |
|
344 |
} |
|
345 |
||
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
346 |
// Used to scan and relocate the classes during CDS archive dump. |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
347 |
void Dictionary::classes_do(MetaspaceClosure* it) { |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
348 |
assert(DumpSharedSpaces, "dump-time only"); |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
349 |
for (int index = 0; index < table_size(); index++) { |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
350 |
for (DictionaryEntry* probe = bucket(index); |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
351 |
probe != NULL; |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
352 |
probe = probe->next()) { |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
353 |
it->push(probe->klass_addr()); |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
354 |
((SharedDictionaryEntry*)probe)->metaspace_pointers_do(it); |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
355 |
} |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
356 |
} |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
357 |
} |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
358 |
|
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
359 |
|
1 | 360 |
|
46729 | 361 |
// Add a loaded class to the dictionary. |
1 | 362 |
// Readers of the SystemDictionary aren't always locked, so _buckets |
363 |
// is volatile. The store of the next field in the constructor is |
|
364 |
// also cast to volatile; we do this to ensure store order is maintained |
|
365 |
// by the compilers. |
|
366 |
||
47774 | 367 |
void Dictionary::add_klass(unsigned int hash, Symbol* class_name, |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46274
diff
changeset
|
368 |
InstanceKlass* obj) { |
1 | 369 |
assert_locked_or_safepoint(SystemDictionary_lock); |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46274
diff
changeset
|
370 |
assert(obj != NULL, "adding NULL obj"); |
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46274
diff
changeset
|
371 |
assert(obj->name() == class_name, "sanity check on name"); |
1 | 372 |
|
46729 | 373 |
DictionaryEntry* entry = new_entry(hash, obj); |
47774 | 374 |
int index = hash_to_index(hash); |
1 | 375 |
add_entry(index, entry); |
47774 | 376 |
check_if_needs_resize(); |
1 | 377 |
} |
378 |
||
379 |
||
46729 | 380 |
// This routine does not lock the dictionary. |
1 | 381 |
// |
382 |
// Since readers don't hold a lock, we must make sure that system |
|
383 |
// dictionary entries are only removed at a safepoint (when only one |
|
384 |
// thread is running), and are added to in a safe way (all links must |
|
385 |
// be updated in an MT-safe manner). |
|
386 |
// |
|
387 |
// Callers should be aware that an entry could be added just after |
|
388 |
// _buckets[index] is read here, so the caller will not see the new entry. |
|
389 |
DictionaryEntry* Dictionary::get_entry(int index, unsigned int hash, |
|
46729 | 390 |
Symbol* class_name) { |
1 | 391 |
for (DictionaryEntry* entry = bucket(index); |
392 |
entry != NULL; |
|
393 |
entry = entry->next()) { |
|
46729 | 394 |
if (entry->hash() == hash && entry->equals(class_name)) { |
395 |
if (!DumpSharedSpaces || SystemDictionaryShared::is_builtin(entry)) { |
|
396 |
return entry; |
|
397 |
} |
|
1 | 398 |
} |
399 |
} |
|
400 |
return NULL; |
|
401 |
} |
|
402 |
||
403 |
||
47774 | 404 |
InstanceKlass* Dictionary::find(unsigned int hash, Symbol* name, |
46729 | 405 |
Handle protection_domain) { |
47774 | 406 |
NoSafepointVerifier nsv; |
407 |
||
408 |
int index = hash_to_index(hash); |
|
46729 | 409 |
DictionaryEntry* entry = get_entry(index, hash, name); |
1 | 410 |
if (entry != NULL && entry->is_valid_protection_domain(protection_domain)) { |
46729 | 411 |
return entry->instance_klass(); |
1 | 412 |
} else { |
413 |
return NULL; |
|
414 |
} |
|
415 |
} |
|
416 |
||
417 |
||
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46274
diff
changeset
|
418 |
InstanceKlass* Dictionary::find_class(int index, unsigned int hash, |
46729 | 419 |
Symbol* name) { |
1 | 420 |
assert_locked_or_safepoint(SystemDictionary_lock); |
46729 | 421 |
assert (index == index_for(name), "incorrect index?"); |
1 | 422 |
|
46729 | 423 |
DictionaryEntry* entry = get_entry(index, hash, name); |
424 |
return (entry != NULL) ? entry->instance_klass() : NULL; |
|
1 | 425 |
} |
426 |
||
427 |
||
428 |
// Variant of find_class for shared classes. No locking required, as |
|
429 |
// that table is static. |
|
430 |
||
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46274
diff
changeset
|
431 |
InstanceKlass* Dictionary::find_shared_class(int index, unsigned int hash, |
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46274
diff
changeset
|
432 |
Symbol* name) { |
46729 | 433 |
assert (index == index_for(name), "incorrect index?"); |
1 | 434 |
|
46729 | 435 |
DictionaryEntry* entry = get_entry(index, hash, name); |
436 |
return (entry != NULL) ? entry->instance_klass() : NULL; |
|
1 | 437 |
} |
438 |
||
439 |
||
440 |
void Dictionary::add_protection_domain(int index, unsigned int hash, |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46274
diff
changeset
|
441 |
InstanceKlass* klass, |
46729 | 442 |
Handle protection_domain, |
1 | 443 |
TRAPS) { |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
444 |
Symbol* klass_name = klass->name(); |
46729 | 445 |
DictionaryEntry* entry = get_entry(index, hash, klass_name); |
1 | 446 |
|
447 |
assert(entry != NULL,"entry must be present, we just created it"); |
|
448 |
assert(protection_domain() != NULL, |
|
449 |
"real protection domain should be present"); |
|
450 |
||
46274
534d019edb92
8175104: Unhandled oop in ProtectionDomainCacheTable::compute_hash
coleenp
parents:
46271
diff
changeset
|
451 |
entry->add_protection_domain(this, protection_domain); |
1 | 452 |
|
48811
58787a1708d2
8175249: VMThread::run fails in VerifyBeforeExit : Universe::verify
coleenp
parents:
48781
diff
changeset
|
453 |
#ifdef ASSERT |
58787a1708d2
8175249: VMThread::run fails in VerifyBeforeExit : Universe::verify
coleenp
parents:
48781
diff
changeset
|
454 |
assert(loader_data() != ClassLoaderData::the_null_class_loader_data(), "doesn't make sense"); |
58787a1708d2
8175249: VMThread::run fails in VerifyBeforeExit : Universe::verify
coleenp
parents:
48781
diff
changeset
|
455 |
#endif |
58787a1708d2
8175249: VMThread::run fails in VerifyBeforeExit : Universe::verify
coleenp
parents:
48781
diff
changeset
|
456 |
|
1 | 457 |
assert(entry->contains_protection_domain(protection_domain()), |
458 |
"now protection domain should be present"); |
|
459 |
} |
|
460 |
||
461 |
||
47774 | 462 |
bool Dictionary::is_valid_protection_domain(unsigned int hash, |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
463 |
Symbol* name, |
1 | 464 |
Handle protection_domain) { |
47774 | 465 |
int index = hash_to_index(hash); |
46729 | 466 |
DictionaryEntry* entry = get_entry(index, hash, name); |
1 | 467 |
return entry->is_valid_protection_domain(protection_domain); |
468 |
} |
|
469 |
||
47761
1b0566927c7a
8190191: Subclasses of jdk.jfr.Event loaded from CDS breaks -XX:FlightRecorderOptions=retransform=false
iklam
parents:
47216
diff
changeset
|
470 |
#if INCLUDE_CDS |
1b0566927c7a
8190191: Subclasses of jdk.jfr.Event loaded from CDS breaks -XX:FlightRecorderOptions=retransform=false
iklam
parents:
47216
diff
changeset
|
471 |
static bool is_jfr_event_class(Klass *k) { |
1b0566927c7a
8190191: Subclasses of jdk.jfr.Event loaded from CDS breaks -XX:FlightRecorderOptions=retransform=false
iklam
parents:
47216
diff
changeset
|
472 |
while (k) { |
1b0566927c7a
8190191: Subclasses of jdk.jfr.Event loaded from CDS breaks -XX:FlightRecorderOptions=retransform=false
iklam
parents:
47216
diff
changeset
|
473 |
if (k->name()->equals("jdk/jfr/Event")) { |
1b0566927c7a
8190191: Subclasses of jdk.jfr.Event loaded from CDS breaks -XX:FlightRecorderOptions=retransform=false
iklam
parents:
47216
diff
changeset
|
474 |
return true; |
1b0566927c7a
8190191: Subclasses of jdk.jfr.Event loaded from CDS breaks -XX:FlightRecorderOptions=retransform=false
iklam
parents:
47216
diff
changeset
|
475 |
} |
1b0566927c7a
8190191: Subclasses of jdk.jfr.Event loaded from CDS breaks -XX:FlightRecorderOptions=retransform=false
iklam
parents:
47216
diff
changeset
|
476 |
k = k->super(); |
1b0566927c7a
8190191: Subclasses of jdk.jfr.Event loaded from CDS breaks -XX:FlightRecorderOptions=retransform=false
iklam
parents:
47216
diff
changeset
|
477 |
} |
1b0566927c7a
8190191: Subclasses of jdk.jfr.Event loaded from CDS breaks -XX:FlightRecorderOptions=retransform=false
iklam
parents:
47216
diff
changeset
|
478 |
return false; |
1b0566927c7a
8190191: Subclasses of jdk.jfr.Event loaded from CDS breaks -XX:FlightRecorderOptions=retransform=false
iklam
parents:
47216
diff
changeset
|
479 |
} |
1 | 480 |
|
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
481 |
void Dictionary::reorder_dictionary_for_sharing() { |
1 | 482 |
|
483 |
// Copy all the dictionary entries into a single master list. |
|
49329 | 484 |
assert(DumpSharedSpaces, "Should only be used at dump time"); |
1 | 485 |
|
486 |
DictionaryEntry* master_list = NULL; |
|
487 |
for (int i = 0; i < table_size(); ++i) { |
|
488 |
DictionaryEntry* p = bucket(i); |
|
489 |
while (p != NULL) { |
|
47103
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
47098
diff
changeset
|
490 |
DictionaryEntry* next = p->next(); |
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
47098
diff
changeset
|
491 |
InstanceKlass*ik = p->instance_klass(); |
49329 | 492 |
if (ik->has_signer_and_not_archived()) { |
47761
1b0566927c7a
8190191: Subclasses of jdk.jfr.Event loaded from CDS breaks -XX:FlightRecorderOptions=retransform=false
iklam
parents:
47216
diff
changeset
|
493 |
// We cannot include signed classes in the archive because the certificates |
1b0566927c7a
8190191: Subclasses of jdk.jfr.Event loaded from CDS breaks -XX:FlightRecorderOptions=retransform=false
iklam
parents:
47216
diff
changeset
|
494 |
// used during dump time may be different than those used during |
1b0566927c7a
8190191: Subclasses of jdk.jfr.Event loaded from CDS breaks -XX:FlightRecorderOptions=retransform=false
iklam
parents:
47216
diff
changeset
|
495 |
// runtime (due to expiration, etc). |
47103
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
47098
diff
changeset
|
496 |
ResourceMark rm; |
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
47098
diff
changeset
|
497 |
tty->print_cr("Preload Warning: Skipping %s from signed JAR", |
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
47098
diff
changeset
|
498 |
ik->name()->as_C_string()); |
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
47098
diff
changeset
|
499 |
free_entry(p); |
47761
1b0566927c7a
8190191: Subclasses of jdk.jfr.Event loaded from CDS breaks -XX:FlightRecorderOptions=retransform=false
iklam
parents:
47216
diff
changeset
|
500 |
} else if (is_jfr_event_class(ik)) { |
1b0566927c7a
8190191: Subclasses of jdk.jfr.Event loaded from CDS breaks -XX:FlightRecorderOptions=retransform=false
iklam
parents:
47216
diff
changeset
|
501 |
// We cannot include JFR event classes because they need runtime-specific |
1b0566927c7a
8190191: Subclasses of jdk.jfr.Event loaded from CDS breaks -XX:FlightRecorderOptions=retransform=false
iklam
parents:
47216
diff
changeset
|
502 |
// instrumentation in order to work with -XX:FlightRecorderOptions=retransform=false. |
1b0566927c7a
8190191: Subclasses of jdk.jfr.Event loaded from CDS breaks -XX:FlightRecorderOptions=retransform=false
iklam
parents:
47216
diff
changeset
|
503 |
// There are only a small number of these classes, so it's not worthwhile to |
1b0566927c7a
8190191: Subclasses of jdk.jfr.Event loaded from CDS breaks -XX:FlightRecorderOptions=retransform=false
iklam
parents:
47216
diff
changeset
|
504 |
// support them and make CDS more complicated. |
1b0566927c7a
8190191: Subclasses of jdk.jfr.Event loaded from CDS breaks -XX:FlightRecorderOptions=retransform=false
iklam
parents:
47216
diff
changeset
|
505 |
ResourceMark rm; |
1b0566927c7a
8190191: Subclasses of jdk.jfr.Event loaded from CDS breaks -XX:FlightRecorderOptions=retransform=false
iklam
parents:
47216
diff
changeset
|
506 |
tty->print_cr("Skipping JFR event class %s", ik->name()->as_C_string()); |
1b0566927c7a
8190191: Subclasses of jdk.jfr.Event loaded from CDS breaks -XX:FlightRecorderOptions=retransform=false
iklam
parents:
47216
diff
changeset
|
507 |
free_entry(p); |
47103
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
47098
diff
changeset
|
508 |
} else { |
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
47098
diff
changeset
|
509 |
p->set_next(master_list); |
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
47098
diff
changeset
|
510 |
master_list = p; |
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
47098
diff
changeset
|
511 |
} |
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
47098
diff
changeset
|
512 |
p = next; |
1 | 513 |
} |
514 |
set_entry(i, NULL); |
|
515 |
} |
|
516 |
||
517 |
// Add the dictionary entries back to the list in the correct buckets. |
|
518 |
while (master_list != NULL) { |
|
519 |
DictionaryEntry* p = master_list; |
|
520 |
master_list = master_list->next(); |
|
521 |
p->set_next(NULL); |
|
46729 | 522 |
Symbol* class_name = p->instance_klass()->name(); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
523 |
// Since the null class loader data isn't copied to the CDS archive, |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
524 |
// compute the hash with NULL for loader data. |
46729 | 525 |
unsigned int hash = compute_hash(class_name); |
1 | 526 |
int index = hash_to_index(hash); |
527 |
p->set_hash(hash); |
|
528 |
p->set_next(bucket(index)); |
|
529 |
set_entry(index, p); |
|
530 |
} |
|
531 |
} |
|
47761
1b0566927c7a
8190191: Subclasses of jdk.jfr.Event loaded from CDS breaks -XX:FlightRecorderOptions=retransform=false
iklam
parents:
47216
diff
changeset
|
532 |
#endif |
35498
392b50de06c6
8146401: Clean up oop.hpp: add inline directives and fix header files
goetz
parents:
34257
diff
changeset
|
533 |
|
2534 | 534 |
SymbolPropertyTable::SymbolPropertyTable(int table_size) |
13195 | 535 |
: Hashtable<Symbol*, mtSymbol>(table_size, sizeof(SymbolPropertyEntry)) |
2534 | 536 |
{ |
537 |
} |
|
13195 | 538 |
SymbolPropertyTable::SymbolPropertyTable(int table_size, HashtableBucket<mtSymbol>* t, |
2534 | 539 |
int number_of_entries) |
13195 | 540 |
: Hashtable<Symbol*, mtSymbol>(table_size, sizeof(SymbolPropertyEntry), t, number_of_entries) |
2534 | 541 |
{ |
542 |
} |
|
543 |
||
544 |
||
545 |
SymbolPropertyEntry* SymbolPropertyTable::find_entry(int index, unsigned int hash, |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
546 |
Symbol* sym, |
5420
586d3988e72b
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
2534
diff
changeset
|
547 |
intptr_t sym_mode) { |
586d3988e72b
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
2534
diff
changeset
|
548 |
assert(index == index_for(sym, sym_mode), "incorrect index?"); |
2534 | 549 |
for (SymbolPropertyEntry* p = bucket(index); p != NULL; p = p->next()) { |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
550 |
if (p->hash() == hash && p->symbol() == sym && p->symbol_mode() == sym_mode) { |
2534 | 551 |
return p; |
552 |
} |
|
553 |
} |
|
554 |
return NULL; |
|
555 |
} |
|
556 |
||
557 |
||
558 |
SymbolPropertyEntry* SymbolPropertyTable::add_entry(int index, unsigned int hash, |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
559 |
Symbol* sym, intptr_t sym_mode) { |
2534 | 560 |
assert_locked_or_safepoint(SystemDictionary_lock); |
5420
586d3988e72b
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
2534
diff
changeset
|
561 |
assert(index == index_for(sym, sym_mode), "incorrect index?"); |
586d3988e72b
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
2534
diff
changeset
|
562 |
assert(find_entry(index, hash, sym, sym_mode) == NULL, "no double entry"); |
2534 | 563 |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
564 |
SymbolPropertyEntry* p = new_entry(hash, sym, sym_mode); |
13195 | 565 |
Hashtable<Symbol*, mtSymbol>::add_entry(index, p); |
2534 | 566 |
return p; |
567 |
} |
|
568 |
||
569 |
void SymbolPropertyTable::oops_do(OopClosure* f) { |
|
570 |
for (int index = 0; index < table_size(); index++) { |
|
571 |
for (SymbolPropertyEntry* p = bucket(index); p != NULL; p = p->next()) { |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
572 |
if (p->method_type() != NULL) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
573 |
f->do_oop(p->method_type_addr()); |
2534 | 574 |
} |
575 |
} |
|
576 |
} |
|
577 |
} |
|
578 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
579 |
void SymbolPropertyTable::methods_do(void f(Method*)) { |
2534 | 580 |
for (int index = 0; index < table_size(); index++) { |
581 |
for (SymbolPropertyEntry* p = bucket(index); p != NULL; p = p->next()) { |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
582 |
Method* prop = p->method(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
583 |
if (prop != NULL) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
584 |
f((Method*)prop); |
2534 | 585 |
} |
586 |
} |
|
587 |
} |
|
588 |
} |
|
589 |
||
1 | 590 |
|
591 |
// ---------------------------------------------------------------------------- |
|
592 |
||
46742 | 593 |
void Dictionary::print_on(outputStream* st) const { |
1 | 594 |
ResourceMark rm; |
595 |
||
46729 | 596 |
assert(loader_data() != NULL, "loader data should not be null"); |
46742 | 597 |
st->print_cr("Java dictionary (table_size=%d, classes=%d)", |
598 |
table_size(), number_of_entries()); |
|
599 |
st->print_cr("^ indicates that initiating loader is different from defining loader"); |
|
1 | 600 |
|
601 |
for (int index = 0; index < table_size(); index++) { |
|
602 |
for (DictionaryEntry* probe = bucket(index); |
|
603 |
probe != NULL; |
|
604 |
probe = probe->next()) { |
|
46729 | 605 |
Klass* e = probe->instance_klass(); |
1 | 606 |
bool is_defining_class = |
46729 | 607 |
(loader_data() == e->class_loader_data()); |
46742 | 608 |
st->print("%4d: %s%s, loader ", index, is_defining_class ? " " : "^", e->external_name()); |
609 |
ClassLoaderData* loader_data = e->class_loader_data(); |
|
610 |
if (loader_data == NULL) { |
|
611 |
// Shared class not restored yet in shared dictionary |
|
612 |
st->print("<shared, not restored>"); |
|
613 |
} else { |
|
614 |
loader_data->print_value_on(st); |
|
39982
1a3808e3f4d9
8138760: [JVMCI] VM warning: Performance bug: SystemDictionary lookup_count=21831450 lookup_length=1275207287 average=58.411479 load=5.572844
gziemski
parents:
38259
diff
changeset
|
615 |
} |
46742 | 616 |
st->cr(); |
1 | 617 |
} |
618 |
} |
|
20405 | 619 |
tty->cr(); |
1 | 620 |
} |
621 |
||
46475
75902cea18af
8166848: Performance bug: SystemDictionary - optimization
coleenp
parents:
46382
diff
changeset
|
622 |
void DictionaryEntry::verify() { |
46729 | 623 |
Klass* e = instance_klass(); |
624 |
guarantee(e->is_instance_klass(), |
|
625 |
"Verify of dictionary failed"); |
|
626 |
e->verify(); |
|
627 |
verify_protection_domain_set(); |
|
628 |
} |
|
629 |
||
630 |
void Dictionary::verify() { |
|
631 |
guarantee(number_of_entries() >= 0, "Verify of dictionary failed"); |
|
632 |
||
46475
75902cea18af
8166848: Performance bug: SystemDictionary - optimization
coleenp
parents:
46382
diff
changeset
|
633 |
ClassLoaderData* cld = loader_data(); |
75902cea18af
8166848: Performance bug: SystemDictionary - optimization
coleenp
parents:
46382
diff
changeset
|
634 |
// class loader must be present; a null class loader is the |
75902cea18af
8166848: Performance bug: SystemDictionary - optimization
coleenp
parents:
46382
diff
changeset
|
635 |
// boostrap loader |
75902cea18af
8166848: Performance bug: SystemDictionary - optimization
coleenp
parents:
46382
diff
changeset
|
636 |
guarantee(cld != NULL || DumpSharedSpaces || |
75902cea18af
8166848: Performance bug: SystemDictionary - optimization
coleenp
parents:
46382
diff
changeset
|
637 |
cld->class_loader() == NULL || |
75902cea18af
8166848: Performance bug: SystemDictionary - optimization
coleenp
parents:
46382
diff
changeset
|
638 |
cld->class_loader()->is_instance(), |
75902cea18af
8166848: Performance bug: SystemDictionary - optimization
coleenp
parents:
46382
diff
changeset
|
639 |
"checking type of class_loader"); |
46729 | 640 |
|
641 |
ResourceMark rm; |
|
642 |
stringStream tempst; |
|
643 |
tempst.print("System Dictionary for %s", cld->loader_name()); |
|
644 |
verify_table<DictionaryEntry>(tempst.as_string()); |
|
42073
89e056fd82cc
8166145: runtime/threads/ThreadInterruptTest3 fails with ExitCode 0
gziemski
parents:
39982
diff
changeset
|
645 |
} |