author | coleenp |
Fri, 28 Jul 2017 10:48:35 -0400 | |
changeset 46729 | c62d2e8b2728 |
parent 46701 | f559541c0daa |
child 46742 | 24ec8a039c90 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
46271
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
42073
diff
changeset
|
2 |
* Copyright (c) 2003, 2017, 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" |
7397 | 28 |
#include "classfile/dictionary.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" |
46701
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46475
diff
changeset
|
32 |
#include "logging/log.hpp" |
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46475
diff
changeset
|
33 |
#include "logging/logStream.hpp" |
20405 | 34 |
#include "memory/iterator.hpp" |
37248 | 35 |
#include "memory/resourceArea.hpp" |
7397 | 36 |
#include "oops/oop.inline.hpp" |
46729 | 37 |
#include "runtime/atomic.hpp" |
24351
61b33cc6d3cf
8042195: Introduce umbrella header orderAccess.inline.hpp.
goetz
parents:
22794
diff
changeset
|
38 |
#include "runtime/orderAccess.inline.hpp" |
7397 | 39 |
#include "utilities/hashtable.inline.hpp" |
1 | 40 |
|
34257
4be3504cc03b
8140802: Clean up and refactor of class loading code for CDS
iklam
parents:
33611
diff
changeset
|
41 |
size_t Dictionary::entry_size() { |
4be3504cc03b
8140802: Clean up and refactor of class loading code for CDS
iklam
parents:
33611
diff
changeset
|
42 |
if (DumpSharedSpaces) { |
4be3504cc03b
8140802: Clean up and refactor of class loading code for CDS
iklam
parents:
33611
diff
changeset
|
43 |
return SystemDictionaryShared::dictionary_entry_size(); |
4be3504cc03b
8140802: Clean up and refactor of class loading code for CDS
iklam
parents:
33611
diff
changeset
|
44 |
} else { |
4be3504cc03b
8140802: Clean up and refactor of class loading code for CDS
iklam
parents:
33611
diff
changeset
|
45 |
return sizeof(DictionaryEntry); |
4be3504cc03b
8140802: Clean up and refactor of class loading code for CDS
iklam
parents:
33611
diff
changeset
|
46 |
} |
4be3504cc03b
8140802: Clean up and refactor of class loading code for CDS
iklam
parents:
33611
diff
changeset
|
47 |
} |
1 | 48 |
|
46729 | 49 |
Dictionary::Dictionary(ClassLoaderData* loader_data, int table_size) |
50 |
: _loader_data(loader_data), Hashtable<InstanceKlass*, mtClass>(table_size, (int)entry_size()) { |
|
1 | 51 |
}; |
52 |
||
53 |
||
46729 | 54 |
Dictionary::Dictionary(ClassLoaderData* loader_data, |
55 |
int table_size, HashtableBucket<mtClass>* t, |
|
1 | 56 |
int number_of_entries) |
46729 | 57 |
: _loader_data(loader_data), Hashtable<InstanceKlass*, mtClass>(table_size, (int)entry_size(), t, number_of_entries) { |
1 | 58 |
}; |
59 |
||
46729 | 60 |
Dictionary::~Dictionary() { |
61 |
DictionaryEntry* probe = NULL; |
|
62 |
for (int index = 0; index < table_size(); index++) { |
|
63 |
for (DictionaryEntry** p = bucket_addr(index); *p != NULL; ) { |
|
64 |
probe = *p; |
|
65 |
*p = probe->next(); |
|
66 |
free_entry(probe); |
|
67 |
} |
|
68 |
} |
|
69 |
assert(number_of_entries() == 0, "should have removed all entries"); |
|
70 |
assert(new_entry_free_list() == NULL, "entry present on Dictionary's free list"); |
|
71 |
free_buckets(); |
|
20405 | 72 |
} |
1 | 73 |
|
46729 | 74 |
DictionaryEntry* Dictionary::new_entry(unsigned int hash, InstanceKlass* klass) { |
75 |
DictionaryEntry* entry = (DictionaryEntry*)Hashtable<InstanceKlass*, mtClass>::allocate_new_entry(hash, klass); |
|
1 | 76 |
entry->set_pd_set(NULL); |
33611
9abd65805e19
8139203: Consistent naming for klass type predicates
coleenp
parents:
33602
diff
changeset
|
77 |
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
|
78 |
if (DumpSharedSpaces) { |
4be3504cc03b
8140802: Clean up and refactor of class loading code for CDS
iklam
parents:
33611
diff
changeset
|
79 |
SystemDictionaryShared::init_shared_dictionary_entry(klass, entry); |
4be3504cc03b
8140802: Clean up and refactor of class loading code for CDS
iklam
parents:
33611
diff
changeset
|
80 |
} |
1 | 81 |
return entry; |
82 |
} |
|
83 |
||
84 |
||
85 |
void Dictionary::free_entry(DictionaryEntry* entry) { |
|
86 |
// avoid recursion when deleting linked list |
|
87 |
while (entry->pd_set() != NULL) { |
|
88 |
ProtectionDomainEntry* to_delete = entry->pd_set(); |
|
89 |
entry->set_pd_set(to_delete->next()); |
|
90 |
delete to_delete; |
|
91 |
} |
|
46729 | 92 |
// Unlink from the Hashtable prior to freeing |
93 |
unlink_entry(entry); |
|
94 |
FREE_C_HEAP_ARRAY(char, entry); |
|
1 | 95 |
} |
96 |
||
97 |
||
98 |
bool DictionaryEntry::contains_protection_domain(oop protection_domain) const { |
|
99 |
#ifdef ASSERT |
|
46729 | 100 |
if (protection_domain == instance_klass()->protection_domain()) { |
1 | 101 |
// Ensure this doesn't show up in the pd_set (invariant) |
102 |
bool in_pd_set = false; |
|
103 |
for (ProtectionDomainEntry* current = _pd_set; |
|
104 |
current != NULL; |
|
105 |
current = current->next()) { |
|
106 |
if (current->protection_domain() == protection_domain) { |
|
107 |
in_pd_set = true; |
|
108 |
break; |
|
109 |
} |
|
110 |
} |
|
111 |
if (in_pd_set) { |
|
112 |
assert(false, "A klass's protection domain should not show up " |
|
113 |
"in its sys. dict. PD set"); |
|
114 |
} |
|
115 |
} |
|
116 |
#endif /* ASSERT */ |
|
117 |
||
46729 | 118 |
if (protection_domain == instance_klass()->protection_domain()) { |
1 | 119 |
// Succeeds trivially |
120 |
return true; |
|
121 |
} |
|
122 |
||
123 |
for (ProtectionDomainEntry* current = _pd_set; |
|
124 |
current != NULL; |
|
125 |
current = current->next()) { |
|
126 |
if (current->protection_domain() == protection_domain) return true; |
|
127 |
} |
|
128 |
return false; |
|
129 |
} |
|
130 |
||
131 |
||
46274
534d019edb92
8175104: Unhandled oop in ProtectionDomainCacheTable::compute_hash
coleenp
parents:
46271
diff
changeset
|
132 |
void DictionaryEntry::add_protection_domain(Dictionary* dict, Handle protection_domain) { |
1 | 133 |
assert_locked_or_safepoint(SystemDictionary_lock); |
46274
534d019edb92
8175104: Unhandled oop in ProtectionDomainCacheTable::compute_hash
coleenp
parents:
46271
diff
changeset
|
134 |
if (!contains_protection_domain(protection_domain())) { |
46729 | 135 |
ProtectionDomainCacheEntry* entry = SystemDictionary::cache_get(protection_domain); |
1 | 136 |
ProtectionDomainEntry* new_head = |
20405 | 137 |
new ProtectionDomainEntry(entry, _pd_set); |
1 | 138 |
// Warning: Preserve store ordering. The SystemDictionary is read |
139 |
// without locks. The new ProtectionDomainEntry must be |
|
140 |
// complete before other threads can be allowed to see it |
|
141 |
// via a store to _pd_set. |
|
142 |
OrderAccess::release_store_ptr(&_pd_set, new_head); |
|
143 |
} |
|
46701
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46475
diff
changeset
|
144 |
LogTarget(Trace, protectiondomain) lt; |
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46475
diff
changeset
|
145 |
if (lt.is_enabled()) { |
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46475
diff
changeset
|
146 |
LogStream ls(lt); |
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46475
diff
changeset
|
147 |
print_count(&ls); |
1 | 148 |
} |
149 |
} |
|
150 |
||
151 |
||
26174
ca46a107cb78
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
25492
diff
changeset
|
152 |
void Dictionary::do_unloading() { |
5402
c51fd0c1d005
6888953: some calls to function-like macros are missing semicolons
jcoomes
parents:
2534
diff
changeset
|
153 |
assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint"); |
1 | 154 |
|
46729 | 155 |
// The NULL class loader doesn't initiate loading classes from other class loaders |
156 |
if (loader_data() == ClassLoaderData::the_null_class_loader_data()) { |
|
157 |
return; |
|
158 |
} |
|
159 |
||
160 |
// Remove unloaded entries and classes from this dictionary |
|
1 | 161 |
DictionaryEntry* probe = NULL; |
26174
ca46a107cb78
8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents:
25492
diff
changeset
|
162 |
for (int index = 0; index < table_size(); index++) { |
1 | 163 |
for (DictionaryEntry** p = bucket_addr(index); *p != NULL; ) { |
164 |
probe = *p; |
|
46729 | 165 |
InstanceKlass* ik = probe->instance_klass(); |
166 |
ClassLoaderData* k_def_class_loader_data = ik->class_loader_data(); |
|
1 | 167 |
|
46729 | 168 |
// If the klass that this loader initiated is dead, |
169 |
// (determined by checking the defining class loader) |
|
170 |
// remove this entry. |
|
171 |
if (k_def_class_loader_data->is_unloading()) { |
|
172 |
assert(k_def_class_loader_data != loader_data(), |
|
173 |
"cannot have live defining loader and unreachable klass"); |
|
174 |
*p = probe->next(); |
|
175 |
free_entry(probe); |
|
176 |
continue; |
|
1 | 177 |
} |
178 |
p = probe->next_addr(); |
|
179 |
} |
|
180 |
} |
|
181 |
} |
|
182 |
||
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25492
diff
changeset
|
183 |
void Dictionary::remove_classes_in_error_state() { |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25492
diff
changeset
|
184 |
assert(DumpSharedSpaces, "supported only when dumping"); |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25492
diff
changeset
|
185 |
DictionaryEntry* probe = NULL; |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25492
diff
changeset
|
186 |
for (int index = 0; index < table_size(); index++) { |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25492
diff
changeset
|
187 |
for (DictionaryEntry** p = bucket_addr(index); *p != NULL; ) { |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25492
diff
changeset
|
188 |
probe = *p; |
46729 | 189 |
InstanceKlass* ik = probe->instance_klass(); |
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25492
diff
changeset
|
190 |
if (ik->is_in_error_state()) { // purge this entry |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25492
diff
changeset
|
191 |
*p = probe->next(); |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25492
diff
changeset
|
192 |
free_entry(probe); |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25492
diff
changeset
|
193 |
ResourceMark rm; |
27618
790a8bf5488b
8064375: Change certain errors to warnings in CDS output.
jiangli
parents:
26181
diff
changeset
|
194 |
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
|
195 |
continue; |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25492
diff
changeset
|
196 |
} |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25492
diff
changeset
|
197 |
|
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25492
diff
changeset
|
198 |
p = probe->next_addr(); |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25492
diff
changeset
|
199 |
} |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25492
diff
changeset
|
200 |
} |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25492
diff
changeset
|
201 |
} |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25492
diff
changeset
|
202 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
203 |
// Just the classes from defining class loaders |
46729 | 204 |
void Dictionary::classes_do(void f(InstanceKlass*)) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
205 |
for (int index = 0; index < table_size(); index++) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
206 |
for (DictionaryEntry* probe = bucket(index); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
207 |
probe != NULL; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
208 |
probe = probe->next()) { |
46729 | 209 |
InstanceKlass* k = probe->instance_klass(); |
210 |
if (loader_data() == k->class_loader_data()) { |
|
1 | 211 |
f(k); |
212 |
} |
|
213 |
} |
|
214 |
} |
|
215 |
} |
|
216 |
||
217 |
// Added for initialize_itable_for_klass to handle exceptions |
|
218 |
// Just the classes from defining class loaders |
|
46729 | 219 |
void Dictionary::classes_do(void f(InstanceKlass*, TRAPS), TRAPS) { |
1 | 220 |
for (int index = 0; index < table_size(); index++) { |
221 |
for (DictionaryEntry* probe = bucket(index); |
|
222 |
probe != NULL; |
|
223 |
probe = probe->next()) { |
|
46729 | 224 |
InstanceKlass* k = probe->instance_klass(); |
225 |
if (loader_data() == k->class_loader_data()) { |
|
1 | 226 |
f(k, CHECK); |
227 |
} |
|
228 |
} |
|
229 |
} |
|
230 |
} |
|
231 |
||
46729 | 232 |
// All classes, and their class loaders, including initiating class loaders |
233 |
void Dictionary::all_entries_do(void f(InstanceKlass*, ClassLoaderData*)) { |
|
1 | 234 |
for (int index = 0; index < table_size(); index++) { |
235 |
for (DictionaryEntry* probe = bucket(index); |
|
236 |
probe != NULL; |
|
237 |
probe = probe->next()) { |
|
46729 | 238 |
InstanceKlass* k = probe->instance_klass(); |
239 |
f(k, loader_data()); |
|
1 | 240 |
} |
241 |
} |
|
242 |
} |
|
243 |
||
244 |
||
46729 | 245 |
// Add a loaded class to the dictionary. |
1 | 246 |
// Readers of the SystemDictionary aren't always locked, so _buckets |
247 |
// is volatile. The store of the next field in the constructor is |
|
248 |
// also cast to volatile; we do this to ensure store order is maintained |
|
249 |
// by the compilers. |
|
250 |
||
46729 | 251 |
void Dictionary::add_klass(int index, unsigned int hash, Symbol* class_name, |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46274
diff
changeset
|
252 |
InstanceKlass* obj) { |
1 | 253 |
assert_locked_or_safepoint(SystemDictionary_lock); |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46274
diff
changeset
|
254 |
assert(obj != NULL, "adding NULL obj"); |
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46274
diff
changeset
|
255 |
assert(obj->name() == class_name, "sanity check on name"); |
1 | 256 |
|
46729 | 257 |
DictionaryEntry* entry = new_entry(hash, obj); |
1 | 258 |
add_entry(index, entry); |
259 |
} |
|
260 |
||
261 |
||
46729 | 262 |
// This routine does not lock the dictionary. |
1 | 263 |
// |
264 |
// Since readers don't hold a lock, we must make sure that system |
|
265 |
// dictionary entries are only removed at a safepoint (when only one |
|
266 |
// thread is running), and are added to in a safe way (all links must |
|
267 |
// be updated in an MT-safe manner). |
|
268 |
// |
|
269 |
// Callers should be aware that an entry could be added just after |
|
270 |
// _buckets[index] is read here, so the caller will not see the new entry. |
|
271 |
DictionaryEntry* Dictionary::get_entry(int index, unsigned int hash, |
|
46729 | 272 |
Symbol* class_name) { |
1 | 273 |
for (DictionaryEntry* entry = bucket(index); |
274 |
entry != NULL; |
|
275 |
entry = entry->next()) { |
|
46729 | 276 |
if (entry->hash() == hash && entry->equals(class_name)) { |
277 |
if (!DumpSharedSpaces || SystemDictionaryShared::is_builtin(entry)) { |
|
278 |
return entry; |
|
279 |
} |
|
1 | 280 |
} |
281 |
} |
|
282 |
return NULL; |
|
283 |
} |
|
284 |
||
285 |
||
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46274
diff
changeset
|
286 |
InstanceKlass* Dictionary::find(int index, unsigned int hash, Symbol* name, |
46729 | 287 |
Handle protection_domain) { |
288 |
DictionaryEntry* entry = get_entry(index, hash, name); |
|
1 | 289 |
if (entry != NULL && entry->is_valid_protection_domain(protection_domain)) { |
46729 | 290 |
return entry->instance_klass(); |
1 | 291 |
} else { |
292 |
return NULL; |
|
293 |
} |
|
294 |
} |
|
295 |
||
296 |
||
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46274
diff
changeset
|
297 |
InstanceKlass* Dictionary::find_class(int index, unsigned int hash, |
46729 | 298 |
Symbol* name) { |
1 | 299 |
assert_locked_or_safepoint(SystemDictionary_lock); |
46729 | 300 |
assert (index == index_for(name), "incorrect index?"); |
1 | 301 |
|
46729 | 302 |
DictionaryEntry* entry = get_entry(index, hash, name); |
303 |
return (entry != NULL) ? entry->instance_klass() : NULL; |
|
1 | 304 |
} |
305 |
||
306 |
||
307 |
// Variant of find_class for shared classes. No locking required, as |
|
308 |
// that table is static. |
|
309 |
||
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46274
diff
changeset
|
310 |
InstanceKlass* Dictionary::find_shared_class(int index, unsigned int hash, |
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46274
diff
changeset
|
311 |
Symbol* name) { |
46729 | 312 |
assert (index == index_for(name), "incorrect index?"); |
1 | 313 |
|
46729 | 314 |
DictionaryEntry* entry = get_entry(index, hash, name); |
315 |
return (entry != NULL) ? entry->instance_klass() : NULL; |
|
1 | 316 |
} |
317 |
||
318 |
||
319 |
void Dictionary::add_protection_domain(int index, unsigned int hash, |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46274
diff
changeset
|
320 |
InstanceKlass* klass, |
46729 | 321 |
Handle protection_domain, |
1 | 322 |
TRAPS) { |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
323 |
Symbol* klass_name = klass->name(); |
46729 | 324 |
DictionaryEntry* entry = get_entry(index, hash, klass_name); |
1 | 325 |
|
326 |
assert(entry != NULL,"entry must be present, we just created it"); |
|
327 |
assert(protection_domain() != NULL, |
|
328 |
"real protection domain should be present"); |
|
329 |
||
46274
534d019edb92
8175104: Unhandled oop in ProtectionDomainCacheTable::compute_hash
coleenp
parents:
46271
diff
changeset
|
330 |
entry->add_protection_domain(this, protection_domain); |
1 | 331 |
|
332 |
assert(entry->contains_protection_domain(protection_domain()), |
|
333 |
"now protection domain should be present"); |
|
334 |
} |
|
335 |
||
336 |
||
337 |
bool Dictionary::is_valid_protection_domain(int index, unsigned int hash, |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
338 |
Symbol* name, |
1 | 339 |
Handle protection_domain) { |
46729 | 340 |
DictionaryEntry* entry = get_entry(index, hash, name); |
1 | 341 |
return entry->is_valid_protection_domain(protection_domain); |
342 |
} |
|
343 |
||
344 |
||
345 |
void Dictionary::reorder_dictionary() { |
|
346 |
||
347 |
// Copy all the dictionary entries into a single master list. |
|
348 |
||
349 |
DictionaryEntry* master_list = NULL; |
|
350 |
for (int i = 0; i < table_size(); ++i) { |
|
351 |
DictionaryEntry* p = bucket(i); |
|
352 |
while (p != NULL) { |
|
353 |
DictionaryEntry* tmp; |
|
354 |
tmp = p->next(); |
|
355 |
p->set_next(master_list); |
|
356 |
master_list = p; |
|
357 |
p = tmp; |
|
358 |
} |
|
359 |
set_entry(i, NULL); |
|
360 |
} |
|
361 |
||
362 |
// Add the dictionary entries back to the list in the correct buckets. |
|
363 |
while (master_list != NULL) { |
|
364 |
DictionaryEntry* p = master_list; |
|
365 |
master_list = master_list->next(); |
|
366 |
p->set_next(NULL); |
|
46729 | 367 |
Symbol* class_name = p->instance_klass()->name(); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
368 |
// 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
|
369 |
// compute the hash with NULL for loader data. |
46729 | 370 |
unsigned int hash = compute_hash(class_name); |
1 | 371 |
int index = hash_to_index(hash); |
372 |
p->set_hash(hash); |
|
373 |
p->set_next(bucket(index)); |
|
374 |
set_entry(index, p); |
|
375 |
} |
|
376 |
} |
|
377 |
||
35498
392b50de06c6
8146401: Clean up oop.hpp: add inline directives and fix header files
goetz
parents:
34257
diff
changeset
|
378 |
|
2534 | 379 |
SymbolPropertyTable::SymbolPropertyTable(int table_size) |
13195 | 380 |
: Hashtable<Symbol*, mtSymbol>(table_size, sizeof(SymbolPropertyEntry)) |
2534 | 381 |
{ |
382 |
} |
|
13195 | 383 |
SymbolPropertyTable::SymbolPropertyTable(int table_size, HashtableBucket<mtSymbol>* t, |
2534 | 384 |
int number_of_entries) |
13195 | 385 |
: Hashtable<Symbol*, mtSymbol>(table_size, sizeof(SymbolPropertyEntry), t, number_of_entries) |
2534 | 386 |
{ |
387 |
} |
|
388 |
||
389 |
||
390 |
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
|
391 |
Symbol* sym, |
5420
586d3988e72b
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
2534
diff
changeset
|
392 |
intptr_t sym_mode) { |
586d3988e72b
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
2534
diff
changeset
|
393 |
assert(index == index_for(sym, sym_mode), "incorrect index?"); |
2534 | 394 |
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
|
395 |
if (p->hash() == hash && p->symbol() == sym && p->symbol_mode() == sym_mode) { |
2534 | 396 |
return p; |
397 |
} |
|
398 |
} |
|
399 |
return NULL; |
|
400 |
} |
|
401 |
||
402 |
||
403 |
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
|
404 |
Symbol* sym, intptr_t sym_mode) { |
2534 | 405 |
assert_locked_or_safepoint(SystemDictionary_lock); |
5420
586d3988e72b
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
2534
diff
changeset
|
406 |
assert(index == index_for(sym, sym_mode), "incorrect index?"); |
586d3988e72b
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
2534
diff
changeset
|
407 |
assert(find_entry(index, hash, sym, sym_mode) == NULL, "no double entry"); |
2534 | 408 |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
409 |
SymbolPropertyEntry* p = new_entry(hash, sym, sym_mode); |
13195 | 410 |
Hashtable<Symbol*, mtSymbol>::add_entry(index, p); |
2534 | 411 |
return p; |
412 |
} |
|
413 |
||
414 |
void SymbolPropertyTable::oops_do(OopClosure* f) { |
|
415 |
for (int index = 0; index < table_size(); index++) { |
|
416 |
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
|
417 |
if (p->method_type() != NULL) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
418 |
f->do_oop(p->method_type_addr()); |
2534 | 419 |
} |
420 |
} |
|
421 |
} |
|
422 |
} |
|
423 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
424 |
void SymbolPropertyTable::methods_do(void f(Method*)) { |
2534 | 425 |
for (int index = 0; index < table_size(); index++) { |
426 |
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
|
427 |
Method* prop = p->method(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
428 |
if (prop != NULL) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
429 |
f((Method*)prop); |
2534 | 430 |
} |
431 |
} |
|
432 |
} |
|
433 |
} |
|
434 |
||
1 | 435 |
|
436 |
// ---------------------------------------------------------------------------- |
|
437 |
||
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25492
diff
changeset
|
438 |
void Dictionary::print(bool details) { |
1 | 439 |
ResourceMark rm; |
440 |
||
46729 | 441 |
assert(loader_data() != NULL, "loader data should not be null"); |
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25492
diff
changeset
|
442 |
if (details) { |
46729 | 443 |
tty->print_cr("Java dictionary (table_size=%d, classes=%d)", |
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25492
diff
changeset
|
444 |
table_size(), number_of_entries()); |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25492
diff
changeset
|
445 |
tty->print_cr("^ indicates that initiating loader is different from " |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25492
diff
changeset
|
446 |
"defining loader"); |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25492
diff
changeset
|
447 |
} |
1 | 448 |
|
449 |
for (int index = 0; index < table_size(); index++) { |
|
450 |
for (DictionaryEntry* probe = bucket(index); |
|
451 |
probe != NULL; |
|
452 |
probe = probe->next()) { |
|
46729 | 453 |
Klass* e = probe->instance_klass(); |
1 | 454 |
bool is_defining_class = |
46729 | 455 |
(loader_data() == e->class_loader_data()); |
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
|
456 |
if (details) { |
42073
89e056fd82cc
8166145: runtime/threads/ThreadInterruptTest3 fails with ExitCode 0
gziemski
parents:
39982
diff
changeset
|
457 |
tty->print("%4d: ", index); |
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
|
458 |
} |
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25492
diff
changeset
|
459 |
tty->print("%s%s", ((!details) || is_defining_class) ? " " : "^", |
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
|
460 |
e->external_name()); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
461 |
|
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25492
diff
changeset
|
462 |
if (details) { |
1 | 463 |
tty->print(", loader "); |
46729 | 464 |
e->class_loader_data()->print_value(); |
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25492
diff
changeset
|
465 |
} |
1 | 466 |
tty->cr(); |
467 |
} |
|
468 |
} |
|
20405 | 469 |
tty->cr(); |
1 | 470 |
} |
471 |
||
46475
75902cea18af
8166848: Performance bug: SystemDictionary - optimization
coleenp
parents:
46382
diff
changeset
|
472 |
void DictionaryEntry::verify() { |
46729 | 473 |
Klass* e = instance_klass(); |
474 |
guarantee(e->is_instance_klass(), |
|
475 |
"Verify of dictionary failed"); |
|
476 |
e->verify(); |
|
477 |
verify_protection_domain_set(); |
|
478 |
} |
|
479 |
||
480 |
void Dictionary::verify() { |
|
481 |
guarantee(number_of_entries() >= 0, "Verify of dictionary failed"); |
|
482 |
||
46475
75902cea18af
8166848: Performance bug: SystemDictionary - optimization
coleenp
parents:
46382
diff
changeset
|
483 |
ClassLoaderData* cld = loader_data(); |
75902cea18af
8166848: Performance bug: SystemDictionary - optimization
coleenp
parents:
46382
diff
changeset
|
484 |
// class loader must be present; a null class loader is the |
75902cea18af
8166848: Performance bug: SystemDictionary - optimization
coleenp
parents:
46382
diff
changeset
|
485 |
// boostrap loader |
75902cea18af
8166848: Performance bug: SystemDictionary - optimization
coleenp
parents:
46382
diff
changeset
|
486 |
guarantee(cld != NULL || DumpSharedSpaces || |
75902cea18af
8166848: Performance bug: SystemDictionary - optimization
coleenp
parents:
46382
diff
changeset
|
487 |
cld->class_loader() == NULL || |
75902cea18af
8166848: Performance bug: SystemDictionary - optimization
coleenp
parents:
46382
diff
changeset
|
488 |
cld->class_loader()->is_instance(), |
75902cea18af
8166848: Performance bug: SystemDictionary - optimization
coleenp
parents:
46382
diff
changeset
|
489 |
"checking type of class_loader"); |
46729 | 490 |
|
491 |
ResourceMark rm; |
|
492 |
stringStream tempst; |
|
493 |
tempst.print("System Dictionary for %s", cld->loader_name()); |
|
494 |
verify_table<DictionaryEntry>(tempst.as_string()); |
|
42073
89e056fd82cc
8166145: runtime/threads/ThreadInterruptTest3 fails with ExitCode 0
gziemski
parents:
39982
diff
changeset
|
495 |
} |
89e056fd82cc
8166145: runtime/threads/ThreadInterruptTest3 fails with ExitCode 0
gziemski
parents:
39982
diff
changeset
|
496 |