src/share/vm/classfile/dictionary.cpp

Mon, 24 Jun 2013 18:55:46 -0400

author
coleenp
date
Mon, 24 Jun 2013 18:55:46 -0400
changeset 5307
e0c9a1d29eb4
parent 5100
43083e670adf
child 5862
82af7d7a0128
permissions
-rw-r--r--

8016325: JVM hangs verifying system dictionary
Summary: Minimize redundant verifications of Klasses.
Reviewed-by: hseigel, jmasa

duke@435 1 /*
acorn@3491 2 * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * questions.
duke@435 22 *
duke@435 23 */
duke@435 24
stefank@2314 25 #include "precompiled.hpp"
stefank@2314 26 #include "classfile/dictionary.hpp"
stefank@2314 27 #include "classfile/systemDictionary.hpp"
stefank@2314 28 #include "oops/oop.inline.hpp"
stefank@2314 29 #include "prims/jvmtiRedefineClassesTrace.hpp"
stefank@2314 30 #include "utilities/hashtable.inline.hpp"
duke@435 31
duke@435 32
duke@435 33 DictionaryEntry* Dictionary::_current_class_entry = NULL;
duke@435 34 int Dictionary::_current_class_index = 0;
duke@435 35
duke@435 36
duke@435 37 Dictionary::Dictionary(int table_size)
coleenp@4037 38 : TwoOopHashtable<Klass*, mtClass>(table_size, sizeof(DictionaryEntry)) {
duke@435 39 _current_class_index = 0;
duke@435 40 _current_class_entry = NULL;
duke@435 41 };
duke@435 42
duke@435 43
duke@435 44
zgu@3900 45 Dictionary::Dictionary(int table_size, HashtableBucket<mtClass>* t,
duke@435 46 int number_of_entries)
coleenp@4037 47 : TwoOopHashtable<Klass*, mtClass>(table_size, sizeof(DictionaryEntry), t, number_of_entries) {
duke@435 48 _current_class_index = 0;
duke@435 49 _current_class_entry = NULL;
duke@435 50 };
duke@435 51
duke@435 52
coleenp@4037 53 DictionaryEntry* Dictionary::new_entry(unsigned int hash, Klass* klass,
coleenp@4037 54 ClassLoaderData* loader_data) {
coleenp@4037 55 DictionaryEntry* entry = (DictionaryEntry*)Hashtable<Klass*, mtClass>::new_entry(hash, klass);
coleenp@4037 56 entry->set_loader_data(loader_data);
duke@435 57 entry->set_pd_set(NULL);
coleenp@4037 58 assert(klass->oop_is_instance(), "Must be");
duke@435 59 return entry;
duke@435 60 }
duke@435 61
duke@435 62
duke@435 63 void Dictionary::free_entry(DictionaryEntry* entry) {
duke@435 64 // avoid recursion when deleting linked list
duke@435 65 while (entry->pd_set() != NULL) {
duke@435 66 ProtectionDomainEntry* to_delete = entry->pd_set();
duke@435 67 entry->set_pd_set(to_delete->next());
duke@435 68 delete to_delete;
duke@435 69 }
coleenp@4037 70 Hashtable<Klass*, mtClass>::free_entry(entry);
duke@435 71 }
duke@435 72
duke@435 73
duke@435 74 bool DictionaryEntry::contains_protection_domain(oop protection_domain) const {
duke@435 75 #ifdef ASSERT
coleenp@4037 76 if (protection_domain == InstanceKlass::cast(klass())->protection_domain()) {
duke@435 77 // Ensure this doesn't show up in the pd_set (invariant)
duke@435 78 bool in_pd_set = false;
duke@435 79 for (ProtectionDomainEntry* current = _pd_set;
duke@435 80 current != NULL;
duke@435 81 current = current->next()) {
duke@435 82 if (current->protection_domain() == protection_domain) {
duke@435 83 in_pd_set = true;
duke@435 84 break;
duke@435 85 }
duke@435 86 }
duke@435 87 if (in_pd_set) {
duke@435 88 assert(false, "A klass's protection domain should not show up "
duke@435 89 "in its sys. dict. PD set");
duke@435 90 }
duke@435 91 }
duke@435 92 #endif /* ASSERT */
duke@435 93
coleenp@4037 94 if (protection_domain == InstanceKlass::cast(klass())->protection_domain()) {
duke@435 95 // Succeeds trivially
duke@435 96 return true;
duke@435 97 }
duke@435 98
duke@435 99 for (ProtectionDomainEntry* current = _pd_set;
duke@435 100 current != NULL;
duke@435 101 current = current->next()) {
duke@435 102 if (current->protection_domain() == protection_domain) return true;
duke@435 103 }
duke@435 104 return false;
duke@435 105 }
duke@435 106
duke@435 107
duke@435 108 void DictionaryEntry::add_protection_domain(oop protection_domain) {
duke@435 109 assert_locked_or_safepoint(SystemDictionary_lock);
duke@435 110 if (!contains_protection_domain(protection_domain)) {
duke@435 111 ProtectionDomainEntry* new_head =
duke@435 112 new ProtectionDomainEntry(protection_domain, _pd_set);
duke@435 113 // Warning: Preserve store ordering. The SystemDictionary is read
duke@435 114 // without locks. The new ProtectionDomainEntry must be
duke@435 115 // complete before other threads can be allowed to see it
duke@435 116 // via a store to _pd_set.
duke@435 117 OrderAccess::release_store_ptr(&_pd_set, new_head);
duke@435 118 }
duke@435 119 if (TraceProtectionDomainVerification && WizardMode) {
duke@435 120 print();
duke@435 121 }
duke@435 122 }
duke@435 123
duke@435 124
coleenp@4037 125 bool Dictionary::do_unloading() {
jcoomes@1844 126 assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint");
duke@435 127 bool class_was_unloaded = false;
duke@435 128 int index = 0; // Defined here for portability! Do not move
duke@435 129
duke@435 130 // Remove unloadable entries and classes from system dictionary
duke@435 131 // The placeholder array has been handled in always_strong_oops_do.
duke@435 132 DictionaryEntry* probe = NULL;
duke@435 133 for (index = 0; index < table_size(); index++) {
duke@435 134 for (DictionaryEntry** p = bucket_addr(index); *p != NULL; ) {
duke@435 135 probe = *p;
coleenp@4037 136 Klass* e = probe->klass();
coleenp@4037 137 ClassLoaderData* loader_data = probe->loader_data();
duke@435 138
coleenp@4037 139 InstanceKlass* ik = InstanceKlass::cast(e);
duke@435 140
duke@435 141 // Non-unloadable classes were handled in always_strong_oops_do
coleenp@4037 142 if (!is_strongly_reachable(loader_data, e)) {
duke@435 143 // Entry was not visited in phase1 (negated test from phase1)
coleenp@4037 144 assert(!loader_data->is_the_null_class_loader_data(), "unloading entry with null class loader");
coleenp@4037 145 ClassLoaderData* k_def_class_loader_data = ik->class_loader_data();
duke@435 146
duke@435 147 // Do we need to delete this system dictionary entry?
duke@435 148 bool purge_entry = false;
duke@435 149
duke@435 150 // Do we need to delete this system dictionary entry?
coleenp@4037 151 if (loader_data->is_unloading()) {
duke@435 152 // If the loader is not live this entry should always be
duke@435 153 // removed (will never be looked up again). Note that this is
duke@435 154 // not the same as unloading the referred class.
coleenp@4037 155 if (k_def_class_loader_data == loader_data) {
duke@435 156 // This is the defining entry, so the referred class is about
duke@435 157 // to be unloaded.
duke@435 158 class_was_unloaded = true;
duke@435 159 }
duke@435 160 // Also remove this system dictionary entry.
duke@435 161 purge_entry = true;
duke@435 162
duke@435 163 } else {
duke@435 164 // The loader in this entry is alive. If the klass is dead,
coleenp@4037 165 // (determined by checking the defining class loader)
duke@435 166 // the loader must be an initiating loader (rather than the
duke@435 167 // defining loader). Remove this entry.
coleenp@4037 168 if (k_def_class_loader_data->is_unloading()) {
coleenp@4037 169 // If we get here, the class_loader_data must not be the defining
duke@435 170 // loader, it must be an initiating one.
coleenp@4037 171 assert(k_def_class_loader_data != loader_data,
duke@435 172 "cannot have live defining loader and unreachable klass");
duke@435 173 // Loader is live, but class and its defining loader are dead.
duke@435 174 // Remove the entry. The class is going away.
duke@435 175 purge_entry = true;
duke@435 176 }
duke@435 177 }
duke@435 178
duke@435 179 if (purge_entry) {
duke@435 180 *p = probe->next();
duke@435 181 if (probe == _current_class_entry) {
duke@435 182 _current_class_entry = NULL;
duke@435 183 }
duke@435 184 free_entry(probe);
duke@435 185 continue;
duke@435 186 }
duke@435 187 }
duke@435 188 p = probe->next_addr();
duke@435 189 }
duke@435 190 }
duke@435 191 return class_was_unloaded;
duke@435 192 }
duke@435 193
duke@435 194
coleenp@4037 195 void Dictionary::always_strong_oops_do(OopClosure* blk) {
duke@435 196 // Follow all system classes and temporary placeholders in dictionary
duke@435 197 for (int index = 0; index < table_size(); index++) {
duke@435 198 for (DictionaryEntry *probe = bucket(index);
duke@435 199 probe != NULL;
duke@435 200 probe = probe->next()) {
coleenp@4037 201 Klass* e = probe->klass();
coleenp@4037 202 ClassLoaderData* loader_data = probe->loader_data();
coleenp@4037 203 if (is_strongly_reachable(loader_data, e)) {
duke@435 204 probe->protection_domain_set_oops_do(blk);
duke@435 205 }
duke@435 206 }
duke@435 207 }
duke@435 208 }
duke@435 209
duke@435 210
coleenp@4037 211 void Dictionary::always_strong_classes_do(KlassClosure* closure) {
coleenp@4037 212 // Follow all system classes and temporary placeholders in dictionary
duke@435 213 for (int index = 0; index < table_size(); index++) {
duke@435 214 for (DictionaryEntry* probe = bucket(index);
duke@435 215 probe != NULL;
duke@435 216 probe = probe->next()) {
coleenp@4037 217 Klass* e = probe->klass();
coleenp@4037 218 ClassLoaderData* loader_data = probe->loader_data();
coleenp@4037 219 if (is_strongly_reachable(loader_data, e)) {
coleenp@4037 220 closure->do_klass(e);
coleenp@4037 221 }
coleenp@4037 222 }
coleenp@4037 223 }
coleenp@4037 224 }
coleenp@4037 225
coleenp@4037 226
coleenp@4037 227 // Just the classes from defining class loaders
coleenp@4037 228 void Dictionary::classes_do(void f(Klass*)) {
coleenp@4037 229 for (int index = 0; index < table_size(); index++) {
coleenp@4037 230 for (DictionaryEntry* probe = bucket(index);
coleenp@4037 231 probe != NULL;
coleenp@4037 232 probe = probe->next()) {
coleenp@4037 233 Klass* k = probe->klass();
coleenp@4037 234 if (probe->loader_data() == InstanceKlass::cast(k)->class_loader_data()) {
duke@435 235 f(k);
duke@435 236 }
duke@435 237 }
duke@435 238 }
duke@435 239 }
duke@435 240
duke@435 241 // Added for initialize_itable_for_klass to handle exceptions
duke@435 242 // Just the classes from defining class loaders
coleenp@4037 243 void Dictionary::classes_do(void f(Klass*, TRAPS), TRAPS) {
duke@435 244 for (int index = 0; index < table_size(); index++) {
duke@435 245 for (DictionaryEntry* probe = bucket(index);
duke@435 246 probe != NULL;
duke@435 247 probe = probe->next()) {
coleenp@4037 248 Klass* k = probe->klass();
coleenp@4037 249 if (probe->loader_data() == InstanceKlass::cast(k)->class_loader_data()) {
duke@435 250 f(k, CHECK);
duke@435 251 }
duke@435 252 }
duke@435 253 }
duke@435 254 }
duke@435 255
duke@435 256 // All classes, and their class loaders
duke@435 257 // Don't iterate over placeholders
coleenp@4037 258 void Dictionary::classes_do(void f(Klass*, ClassLoaderData*)) {
duke@435 259 for (int index = 0; index < table_size(); index++) {
duke@435 260 for (DictionaryEntry* probe = bucket(index);
duke@435 261 probe != NULL;
duke@435 262 probe = probe->next()) {
coleenp@4037 263 Klass* k = probe->klass();
coleenp@4037 264 f(k, probe->loader_data());
duke@435 265 }
duke@435 266 }
duke@435 267 }
duke@435 268
duke@435 269
duke@435 270 void Dictionary::oops_do(OopClosure* f) {
duke@435 271 for (int index = 0; index < table_size(); index++) {
duke@435 272 for (DictionaryEntry* probe = bucket(index);
duke@435 273 probe != NULL;
duke@435 274 probe = probe->next()) {
duke@435 275 probe->protection_domain_set_oops_do(f);
duke@435 276 }
duke@435 277 }
duke@435 278 }
duke@435 279
duke@435 280
coleenp@4037 281 void Dictionary::methods_do(void f(Method*)) {
duke@435 282 for (int index = 0; index < table_size(); index++) {
duke@435 283 for (DictionaryEntry* probe = bucket(index);
duke@435 284 probe != NULL;
duke@435 285 probe = probe->next()) {
coleenp@4037 286 Klass* k = probe->klass();
coleenp@4037 287 if (probe->loader_data() == InstanceKlass::cast(k)->class_loader_data()) {
duke@435 288 // only take klass is we have the entry with the defining class loader
coleenp@4037 289 InstanceKlass::cast(k)->methods_do(f);
duke@435 290 }
duke@435 291 }
duke@435 292 }
duke@435 293 }
duke@435 294
duke@435 295
coleenp@4037 296 Klass* Dictionary::try_get_next_class() {
duke@435 297 while (true) {
duke@435 298 if (_current_class_entry != NULL) {
coleenp@4037 299 Klass* k = _current_class_entry->klass();
duke@435 300 _current_class_entry = _current_class_entry->next();
duke@435 301 return k;
duke@435 302 }
duke@435 303 _current_class_index = (_current_class_index + 1) % table_size();
duke@435 304 _current_class_entry = bucket(_current_class_index);
duke@435 305 }
duke@435 306 // never reached
duke@435 307 }
duke@435 308
duke@435 309
duke@435 310 // Add a loaded class to the system dictionary.
duke@435 311 // Readers of the SystemDictionary aren't always locked, so _buckets
duke@435 312 // is volatile. The store of the next field in the constructor is
duke@435 313 // also cast to volatile; we do this to ensure store order is maintained
duke@435 314 // by the compilers.
duke@435 315
coleenp@4037 316 void Dictionary::add_klass(Symbol* class_name, ClassLoaderData* loader_data,
duke@435 317 KlassHandle obj) {
duke@435 318 assert_locked_or_safepoint(SystemDictionary_lock);
duke@435 319 assert(obj() != NULL, "adding NULL obj");
hseigel@4278 320 assert(obj()->name() == class_name, "sanity check on name");
stefank@4667 321 assert(loader_data != NULL, "Must be non-NULL");
duke@435 322
coleenp@4037 323 unsigned int hash = compute_hash(class_name, loader_data);
duke@435 324 int index = hash_to_index(hash);
coleenp@4037 325 DictionaryEntry* entry = new_entry(hash, obj(), loader_data);
duke@435 326 add_entry(index, entry);
duke@435 327 }
duke@435 328
duke@435 329
duke@435 330 // This routine does not lock the system dictionary.
duke@435 331 //
duke@435 332 // Since readers don't hold a lock, we must make sure that system
duke@435 333 // dictionary entries are only removed at a safepoint (when only one
duke@435 334 // thread is running), and are added to in a safe way (all links must
duke@435 335 // be updated in an MT-safe manner).
duke@435 336 //
duke@435 337 // Callers should be aware that an entry could be added just after
duke@435 338 // _buckets[index] is read here, so the caller will not see the new entry.
duke@435 339 DictionaryEntry* Dictionary::get_entry(int index, unsigned int hash,
coleenp@2497 340 Symbol* class_name,
coleenp@4037 341 ClassLoaderData* loader_data) {
duke@435 342 debug_only(_lookup_count++);
duke@435 343 for (DictionaryEntry* entry = bucket(index);
duke@435 344 entry != NULL;
duke@435 345 entry = entry->next()) {
coleenp@4037 346 if (entry->hash() == hash && entry->equals(class_name, loader_data)) {
duke@435 347 return entry;
duke@435 348 }
duke@435 349 debug_only(_lookup_length++);
duke@435 350 }
duke@435 351 return NULL;
duke@435 352 }
duke@435 353
duke@435 354
coleenp@4037 355 Klass* Dictionary::find(int index, unsigned int hash, Symbol* name,
coleenp@4037 356 ClassLoaderData* loader_data, Handle protection_domain, TRAPS) {
coleenp@4037 357 DictionaryEntry* entry = get_entry(index, hash, name, loader_data);
duke@435 358 if (entry != NULL && entry->is_valid_protection_domain(protection_domain)) {
duke@435 359 return entry->klass();
duke@435 360 } else {
duke@435 361 return NULL;
duke@435 362 }
duke@435 363 }
duke@435 364
duke@435 365
coleenp@4037 366 Klass* Dictionary::find_class(int index, unsigned int hash,
coleenp@4037 367 Symbol* name, ClassLoaderData* loader_data) {
duke@435 368 assert_locked_or_safepoint(SystemDictionary_lock);
coleenp@4037 369 assert (index == index_for(name, loader_data), "incorrect index?");
duke@435 370
coleenp@4037 371 DictionaryEntry* entry = get_entry(index, hash, name, loader_data);
coleenp@4037 372 return (entry != NULL) ? entry->klass() : (Klass*)NULL;
duke@435 373 }
duke@435 374
duke@435 375
duke@435 376 // Variant of find_class for shared classes. No locking required, as
duke@435 377 // that table is static.
duke@435 378
coleenp@4037 379 Klass* Dictionary::find_shared_class(int index, unsigned int hash,
coleenp@2497 380 Symbol* name) {
coleenp@4037 381 assert (index == index_for(name, NULL), "incorrect index?");
duke@435 382
coleenp@4037 383 DictionaryEntry* entry = get_entry(index, hash, name, NULL);
coleenp@4037 384 return (entry != NULL) ? entry->klass() : (Klass*)NULL;
duke@435 385 }
duke@435 386
duke@435 387
duke@435 388 void Dictionary::add_protection_domain(int index, unsigned int hash,
duke@435 389 instanceKlassHandle klass,
coleenp@4037 390 ClassLoaderData* loader_data, Handle protection_domain,
duke@435 391 TRAPS) {
coleenp@2497 392 Symbol* klass_name = klass->name();
coleenp@4037 393 DictionaryEntry* entry = get_entry(index, hash, klass_name, loader_data);
duke@435 394
duke@435 395 assert(entry != NULL,"entry must be present, we just created it");
duke@435 396 assert(protection_domain() != NULL,
duke@435 397 "real protection domain should be present");
duke@435 398
duke@435 399 entry->add_protection_domain(protection_domain());
duke@435 400
duke@435 401 assert(entry->contains_protection_domain(protection_domain()),
duke@435 402 "now protection domain should be present");
duke@435 403 }
duke@435 404
duke@435 405
duke@435 406 bool Dictionary::is_valid_protection_domain(int index, unsigned int hash,
coleenp@2497 407 Symbol* name,
coleenp@4037 408 ClassLoaderData* loader_data,
duke@435 409 Handle protection_domain) {
coleenp@4037 410 DictionaryEntry* entry = get_entry(index, hash, name, loader_data);
duke@435 411 return entry->is_valid_protection_domain(protection_domain);
duke@435 412 }
duke@435 413
duke@435 414
duke@435 415 void Dictionary::reorder_dictionary() {
duke@435 416
duke@435 417 // Copy all the dictionary entries into a single master list.
duke@435 418
duke@435 419 DictionaryEntry* master_list = NULL;
duke@435 420 for (int i = 0; i < table_size(); ++i) {
duke@435 421 DictionaryEntry* p = bucket(i);
duke@435 422 while (p != NULL) {
duke@435 423 DictionaryEntry* tmp;
duke@435 424 tmp = p->next();
duke@435 425 p->set_next(master_list);
duke@435 426 master_list = p;
duke@435 427 p = tmp;
duke@435 428 }
duke@435 429 set_entry(i, NULL);
duke@435 430 }
duke@435 431
duke@435 432 // Add the dictionary entries back to the list in the correct buckets.
duke@435 433 while (master_list != NULL) {
duke@435 434 DictionaryEntry* p = master_list;
duke@435 435 master_list = master_list->next();
duke@435 436 p->set_next(NULL);
coleenp@4037 437 Symbol* class_name = InstanceKlass::cast((Klass*)(p->klass()))->name();
coleenp@4037 438 // Since the null class loader data isn't copied to the CDS archive,
coleenp@4037 439 // compute the hash with NULL for loader data.
coleenp@4037 440 unsigned int hash = compute_hash(class_name, NULL);
duke@435 441 int index = hash_to_index(hash);
duke@435 442 p->set_hash(hash);
coleenp@4037 443 p->set_loader_data(NULL); // loader_data isn't copied to CDS
duke@435 444 p->set_next(bucket(index));
duke@435 445 set_entry(index, p);
duke@435 446 }
duke@435 447 }
duke@435 448
jrose@1145 449 SymbolPropertyTable::SymbolPropertyTable(int table_size)
zgu@3900 450 : Hashtable<Symbol*, mtSymbol>(table_size, sizeof(SymbolPropertyEntry))
jrose@1145 451 {
jrose@1145 452 }
zgu@3900 453 SymbolPropertyTable::SymbolPropertyTable(int table_size, HashtableBucket<mtSymbol>* t,
jrose@1145 454 int number_of_entries)
zgu@3900 455 : Hashtable<Symbol*, mtSymbol>(table_size, sizeof(SymbolPropertyEntry), t, number_of_entries)
jrose@1145 456 {
jrose@1145 457 }
jrose@1145 458
jrose@1145 459
jrose@1145 460 SymbolPropertyEntry* SymbolPropertyTable::find_entry(int index, unsigned int hash,
coleenp@2497 461 Symbol* sym,
jrose@1862 462 intptr_t sym_mode) {
jrose@1862 463 assert(index == index_for(sym, sym_mode), "incorrect index?");
jrose@1145 464 for (SymbolPropertyEntry* p = bucket(index); p != NULL; p = p->next()) {
coleenp@2497 465 if (p->hash() == hash && p->symbol() == sym && p->symbol_mode() == sym_mode) {
jrose@1145 466 return p;
jrose@1145 467 }
jrose@1145 468 }
jrose@1145 469 return NULL;
jrose@1145 470 }
jrose@1145 471
jrose@1145 472
jrose@1145 473 SymbolPropertyEntry* SymbolPropertyTable::add_entry(int index, unsigned int hash,
coleenp@2497 474 Symbol* sym, intptr_t sym_mode) {
jrose@1145 475 assert_locked_or_safepoint(SystemDictionary_lock);
jrose@1862 476 assert(index == index_for(sym, sym_mode), "incorrect index?");
jrose@1862 477 assert(find_entry(index, hash, sym, sym_mode) == NULL, "no double entry");
jrose@1145 478
coleenp@2497 479 SymbolPropertyEntry* p = new_entry(hash, sym, sym_mode);
zgu@3900 480 Hashtable<Symbol*, mtSymbol>::add_entry(index, p);
jrose@1145 481 return p;
jrose@1145 482 }
jrose@1145 483
jrose@1145 484 void SymbolPropertyTable::oops_do(OopClosure* f) {
jrose@1145 485 for (int index = 0; index < table_size(); index++) {
jrose@1145 486 for (SymbolPropertyEntry* p = bucket(index); p != NULL; p = p->next()) {
coleenp@4037 487 if (p->method_type() != NULL) {
coleenp@4037 488 f->do_oop(p->method_type_addr());
jrose@1145 489 }
jrose@1145 490 }
jrose@1145 491 }
jrose@1145 492 }
jrose@1145 493
coleenp@4037 494 void SymbolPropertyTable::methods_do(void f(Method*)) {
jrose@1145 495 for (int index = 0; index < table_size(); index++) {
jrose@1145 496 for (SymbolPropertyEntry* p = bucket(index); p != NULL; p = p->next()) {
coleenp@4037 497 Method* prop = p->method();
coleenp@4037 498 if (prop != NULL) {
coleenp@4037 499 f((Method*)prop);
jrose@1145 500 }
jrose@1145 501 }
jrose@1145 502 }
jrose@1145 503 }
jrose@1145 504
duke@435 505
duke@435 506 // ----------------------------------------------------------------------------
duke@435 507 #ifndef PRODUCT
duke@435 508
duke@435 509 void Dictionary::print() {
duke@435 510 ResourceMark rm;
duke@435 511 HandleMark hm;
duke@435 512
acorn@3491 513 tty->print_cr("Java system dictionary (table_size=%d, classes=%d)",
acorn@3491 514 table_size(), number_of_entries());
duke@435 515 tty->print_cr("^ indicates that initiating loader is different from "
duke@435 516 "defining loader");
duke@435 517
duke@435 518 for (int index = 0; index < table_size(); index++) {
duke@435 519 for (DictionaryEntry* probe = bucket(index);
duke@435 520 probe != NULL;
duke@435 521 probe = probe->next()) {
duke@435 522 if (Verbose) tty->print("%4d: ", index);
coleenp@4037 523 Klass* e = probe->klass();
coleenp@4037 524 ClassLoaderData* loader_data = probe->loader_data();
duke@435 525 bool is_defining_class =
coleenp@4037 526 (loader_data == InstanceKlass::cast(e)->class_loader_data());
duke@435 527 tty->print("%s%s", is_defining_class ? " " : "^",
hseigel@4278 528 e->external_name());
coleenp@4037 529
duke@435 530 tty->print(", loader ");
coleenp@4037 531 loader_data->print_value();
duke@435 532 tty->cr();
duke@435 533 }
duke@435 534 }
duke@435 535 }
duke@435 536
duke@435 537 #endif
duke@435 538
coleenp@4037 539
duke@435 540 void Dictionary::verify() {
duke@435 541 guarantee(number_of_entries() >= 0, "Verify of system dictionary failed");
coleenp@4037 542
duke@435 543 int element_count = 0;
duke@435 544 for (int index = 0; index < table_size(); index++) {
duke@435 545 for (DictionaryEntry* probe = bucket(index);
duke@435 546 probe != NULL;
duke@435 547 probe = probe->next()) {
coleenp@4037 548 Klass* e = probe->klass();
coleenp@4037 549 ClassLoaderData* loader_data = probe->loader_data();
hseigel@4278 550 guarantee(e->oop_is_instance(),
duke@435 551 "Verify of system dictionary failed");
duke@435 552 // class loader must be present; a null class loader is the
duke@435 553 // boostrap loader
coleenp@4037 554 guarantee(loader_data != NULL || DumpSharedSpaces ||
coleenp@4304 555 loader_data->class_loader() == NULL ||
coleenp@4037 556 loader_data->class_loader()->is_instance(),
duke@435 557 "checking type of class_loader");
coleenp@5307 558 e->verify(/*check_dictionary*/false);
duke@435 559 probe->verify_protection_domain_set();
duke@435 560 element_count++;
duke@435 561 }
duke@435 562 }
duke@435 563 guarantee(number_of_entries() == element_count,
duke@435 564 "Verify of system dictionary failed");
duke@435 565 debug_only(verify_lookup_length((double)number_of_entries() / table_size()));
duke@435 566 }
coleenp@4037 567

mercurial