344 Klass* k = _current_class_entry->klass();
345 _current_class_entry = _current_class_entry->next();
346 return k;
347 }
348 _current_class_index = (_current_class_index + 1) % table_size();
349 _current_class_entry = bucket(_current_class_index);
350 }
351 // never reached
352 }
353
354 // Add a loaded class to the system dictionary.
355 // Readers of the SystemDictionary aren't always locked, so _buckets
356 // is volatile. The store of the next field in the constructor is
357 // also cast to volatile; we do this to ensure store order is maintained
358 // by the compilers.
359
360 void Dictionary::add_klass(Symbol* class_name, ClassLoaderData* loader_data,
361 KlassHandle obj) {
362 assert_locked_or_safepoint(SystemDictionary_lock);
363 assert(obj() != NULL, "adding NULL obj");
364 assert(obj()->name() == class_name, "sanity check on name");
365 assert(loader_data != NULL, "Must be non-NULL");
366
367 unsigned int hash = compute_hash(class_name, loader_data);
368 int index = hash_to_index(hash);
369 DictionaryEntry* entry = new_entry(hash, obj(), loader_data);
370 add_entry(index, entry);
371 }
372
373
374 // This routine does not lock the system dictionary.
375 //
376 // Since readers don't hold a lock, we must make sure that system
377 // dictionary entries are only removed at a safepoint (when only one
378 // thread is running), and are added to in a safe way (all links must
379 // be updated in an MT-safe manner).
380 //
381 // Callers should be aware that an entry could be added just after
382 // _buckets[index] is read here, so the caller will not see the new entry.
383 DictionaryEntry* Dictionary::get_entry(int index, unsigned int hash,
384 Symbol* class_name,
646 }
647 }
648 }
649
650 SymbolPropertyTable::SymbolPropertyTable(int table_size)
651 : Hashtable<Symbol*, mtSymbol>(table_size, sizeof(SymbolPropertyEntry))
652 {
653 }
654 SymbolPropertyTable::SymbolPropertyTable(int table_size, HashtableBucket<mtSymbol>* t,
655 int number_of_entries)
656 : Hashtable<Symbol*, mtSymbol>(table_size, sizeof(SymbolPropertyEntry), t, number_of_entries)
657 {
658 }
659
660
661 SymbolPropertyEntry* SymbolPropertyTable::find_entry(int index, unsigned int hash,
662 Symbol* sym,
663 intptr_t sym_mode) {
664 assert(index == index_for(sym, sym_mode), "incorrect index?");
665 for (SymbolPropertyEntry* p = bucket(index); p != NULL; p = p->next()) {
666 if (p->hash() == hash && p->symbol() == sym && p->symbol_mode() == sym_mode) {
667 return p;
668 }
669 }
670 return NULL;
671 }
672
673
674 SymbolPropertyEntry* SymbolPropertyTable::add_entry(int index, unsigned int hash,
675 Symbol* sym, intptr_t sym_mode) {
676 assert_locked_or_safepoint(SystemDictionary_lock);
677 assert(index == index_for(sym, sym_mode), "incorrect index?");
678 assert(find_entry(index, hash, sym, sym_mode) == NULL, "no double entry");
679
680 SymbolPropertyEntry* p = new_entry(hash, sym, sym_mode);
681 Hashtable<Symbol*, mtSymbol>::add_entry(index, p);
682 return p;
683 }
684
685 void SymbolPropertyTable::oops_do(OopClosure* f) {
686 for (int index = 0; index < table_size(); index++) {
|
344 Klass* k = _current_class_entry->klass();
345 _current_class_entry = _current_class_entry->next();
346 return k;
347 }
348 _current_class_index = (_current_class_index + 1) % table_size();
349 _current_class_entry = bucket(_current_class_index);
350 }
351 // never reached
352 }
353
354 // Add a loaded class to the system dictionary.
355 // Readers of the SystemDictionary aren't always locked, so _buckets
356 // is volatile. The store of the next field in the constructor is
357 // also cast to volatile; we do this to ensure store order is maintained
358 // by the compilers.
359
360 void Dictionary::add_klass(Symbol* class_name, ClassLoaderData* loader_data,
361 KlassHandle obj) {
362 assert_locked_or_safepoint(SystemDictionary_lock);
363 assert(obj() != NULL, "adding NULL obj");
364 assert(obj()->name()->equals(class_name), "sanity check on name");
365 assert(loader_data != NULL, "Must be non-NULL");
366
367 unsigned int hash = compute_hash(class_name, loader_data);
368 int index = hash_to_index(hash);
369 DictionaryEntry* entry = new_entry(hash, obj(), loader_data);
370 add_entry(index, entry);
371 }
372
373
374 // This routine does not lock the system dictionary.
375 //
376 // Since readers don't hold a lock, we must make sure that system
377 // dictionary entries are only removed at a safepoint (when only one
378 // thread is running), and are added to in a safe way (all links must
379 // be updated in an MT-safe manner).
380 //
381 // Callers should be aware that an entry could be added just after
382 // _buckets[index] is read here, so the caller will not see the new entry.
383 DictionaryEntry* Dictionary::get_entry(int index, unsigned int hash,
384 Symbol* class_name,
646 }
647 }
648 }
649
650 SymbolPropertyTable::SymbolPropertyTable(int table_size)
651 : Hashtable<Symbol*, mtSymbol>(table_size, sizeof(SymbolPropertyEntry))
652 {
653 }
654 SymbolPropertyTable::SymbolPropertyTable(int table_size, HashtableBucket<mtSymbol>* t,
655 int number_of_entries)
656 : Hashtable<Symbol*, mtSymbol>(table_size, sizeof(SymbolPropertyEntry), t, number_of_entries)
657 {
658 }
659
660
661 SymbolPropertyEntry* SymbolPropertyTable::find_entry(int index, unsigned int hash,
662 Symbol* sym,
663 intptr_t sym_mode) {
664 assert(index == index_for(sym, sym_mode), "incorrect index?");
665 for (SymbolPropertyEntry* p = bucket(index); p != NULL; p = p->next()) {
666 if (p->hash() == hash && p->symbol()->equals(sym) && p->symbol_mode() == sym_mode) {
667 return p;
668 }
669 }
670 return NULL;
671 }
672
673
674 SymbolPropertyEntry* SymbolPropertyTable::add_entry(int index, unsigned int hash,
675 Symbol* sym, intptr_t sym_mode) {
676 assert_locked_or_safepoint(SystemDictionary_lock);
677 assert(index == index_for(sym, sym_mode), "incorrect index?");
678 assert(find_entry(index, hash, sym, sym_mode) == NULL, "no double entry");
679
680 SymbolPropertyEntry* p = new_entry(hash, sym, sym_mode);
681 Hashtable<Symbol*, mtSymbol>::add_entry(index, p);
682 return p;
683 }
684
685 void SymbolPropertyTable::oops_do(OopClosure* f) {
686 for (int index = 0; index < table_size(); index++) {
|