< prev index next >
src/share/vm/classfile/dictionary.cpp
Print this page
*** 44,75 ****
return sizeof(DictionaryEntry);
}
}
Dictionary::Dictionary(int table_size)
! : TwoOopHashtable<Klass*, mtClass>(table_size, (int)entry_size()) {
_current_class_index = 0;
_current_class_entry = NULL;
_pd_cache_table = new ProtectionDomainCacheTable(defaultProtectionDomainCacheSize);
};
Dictionary::Dictionary(int table_size, HashtableBucket<mtClass>* t,
int number_of_entries)
! : TwoOopHashtable<Klass*, mtClass>(table_size, (int)entry_size(), t, number_of_entries) {
_current_class_index = 0;
_current_class_entry = NULL;
_pd_cache_table = new ProtectionDomainCacheTable(defaultProtectionDomainCacheSize);
};
ProtectionDomainCacheEntry* Dictionary::cache_get(Handle protection_domain) {
return _pd_cache_table->get(protection_domain);
}
! DictionaryEntry* Dictionary::new_entry(unsigned int hash, Klass* klass,
ClassLoaderData* loader_data) {
! DictionaryEntry* entry = (DictionaryEntry*)Hashtable<Klass*, mtClass>::new_entry(hash, klass);
entry->set_loader_data(loader_data);
entry->set_pd_set(NULL);
assert(klass->is_instance_klass(), "Must be");
if (DumpSharedSpaces) {
SystemDictionaryShared::init_shared_dictionary_entry(klass, entry);
--- 44,75 ----
return sizeof(DictionaryEntry);
}
}
Dictionary::Dictionary(int table_size)
! : TwoOopHashtable<InstanceKlass*, mtClass>(table_size, (int)entry_size()) {
_current_class_index = 0;
_current_class_entry = NULL;
_pd_cache_table = new ProtectionDomainCacheTable(defaultProtectionDomainCacheSize);
};
Dictionary::Dictionary(int table_size, HashtableBucket<mtClass>* t,
int number_of_entries)
! : TwoOopHashtable<InstanceKlass*, mtClass>(table_size, (int)entry_size(), t, number_of_entries) {
_current_class_index = 0;
_current_class_entry = NULL;
_pd_cache_table = new ProtectionDomainCacheTable(defaultProtectionDomainCacheSize);
};
ProtectionDomainCacheEntry* Dictionary::cache_get(Handle protection_domain) {
return _pd_cache_table->get(protection_domain);
}
! DictionaryEntry* Dictionary::new_entry(unsigned int hash, InstanceKlass* klass,
ClassLoaderData* loader_data) {
! DictionaryEntry* entry = (DictionaryEntry*)Hashtable<InstanceKlass*, mtClass>::new_entry(hash, klass);
entry->set_loader_data(loader_data);
entry->set_pd_set(NULL);
assert(klass->is_instance_klass(), "Must be");
if (DumpSharedSpaces) {
SystemDictionaryShared::init_shared_dictionary_entry(klass, entry);
*** 83,93 ****
while (entry->pd_set() != NULL) {
ProtectionDomainEntry* to_delete = entry->pd_set();
entry->set_pd_set(to_delete->next());
delete to_delete;
}
! Hashtable<Klass*, mtClass>::free_entry(entry);
}
bool DictionaryEntry::contains_protection_domain(oop protection_domain) const {
#ifdef ASSERT
--- 83,93 ----
while (entry->pd_set() != NULL) {
ProtectionDomainEntry* to_delete = entry->pd_set();
entry->set_pd_set(to_delete->next());
delete to_delete;
}
! Hashtable<InstanceKlass*, mtClass>::free_entry(entry);
}
bool DictionaryEntry::contains_protection_domain(oop protection_domain) const {
#ifdef ASSERT
*** 349,362 ****
// Only the protection domain cache table may contain references to the heap
// that need to be unlinked.
_pd_cache_table->unlink(is_alive);
}
! Klass* Dictionary::try_get_next_class() {
while (true) {
if (_current_class_entry != NULL) {
! Klass* k = _current_class_entry->klass();
_current_class_entry = _current_class_entry->next();
return k;
}
_current_class_index = (_current_class_index + 1) % table_size();
_current_class_entry = bucket(_current_class_index);
--- 349,362 ----
// Only the protection domain cache table may contain references to the heap
// that need to be unlinked.
_pd_cache_table->unlink(is_alive);
}
! InstanceKlass* Dictionary::try_get_next_class() {
while (true) {
if (_current_class_entry != NULL) {
! InstanceKlass* k = _current_class_entry->klass();
_current_class_entry = _current_class_entry->next();
return k;
}
_current_class_index = (_current_class_index + 1) % table_size();
_current_class_entry = bucket(_current_class_index);
*** 369,387 ****
// is volatile. The store of the next field in the constructor is
// also cast to volatile; we do this to ensure store order is maintained
// by the compilers.
void Dictionary::add_klass(Symbol* class_name, ClassLoaderData* loader_data,
! KlassHandle obj) {
assert_locked_or_safepoint(SystemDictionary_lock);
! assert(obj() != NULL, "adding NULL obj");
! assert(obj()->name() == class_name, "sanity check on name");
assert(loader_data != NULL, "Must be non-NULL");
unsigned int hash = compute_hash(class_name, loader_data);
int index = hash_to_index(hash);
! DictionaryEntry* entry = new_entry(hash, obj(), loader_data);
add_entry(index, entry);
}
// This routine does not lock the system dictionary.
--- 369,387 ----
// is volatile. The store of the next field in the constructor is
// also cast to volatile; we do this to ensure store order is maintained
// by the compilers.
void Dictionary::add_klass(Symbol* class_name, ClassLoaderData* loader_data,
! InstanceKlass* obj) {
assert_locked_or_safepoint(SystemDictionary_lock);
! assert(obj != NULL, "adding NULL obj");
! assert(obj->name() == class_name, "sanity check on name");
assert(loader_data != NULL, "Must be non-NULL");
unsigned int hash = compute_hash(class_name, loader_data);
int index = hash_to_index(hash);
! DictionaryEntry* entry = new_entry(hash, obj, loader_data);
add_entry(index, entry);
}
// This routine does not lock the system dictionary.
*** 408,452 ****
}
return NULL;
}
! Klass* Dictionary::find(int index, unsigned int hash, Symbol* name,
ClassLoaderData* loader_data, Handle protection_domain, TRAPS) {
DictionaryEntry* entry = get_entry(index, hash, name, loader_data);
if (entry != NULL && entry->is_valid_protection_domain(protection_domain)) {
return entry->klass();
} else {
return NULL;
}
}
! Klass* Dictionary::find_class(int index, unsigned int hash,
Symbol* name, ClassLoaderData* loader_data) {
assert_locked_or_safepoint(SystemDictionary_lock);
assert (index == index_for(name, loader_data), "incorrect index?");
DictionaryEntry* entry = get_entry(index, hash, name, loader_data);
! return (entry != NULL) ? entry->klass() : (Klass*)NULL;
}
// Variant of find_class for shared classes. No locking required, as
// that table is static.
! Klass* Dictionary::find_shared_class(int index, unsigned int hash,
Symbol* name) {
assert (index == index_for(name, NULL), "incorrect index?");
DictionaryEntry* entry = get_entry(index, hash, name, NULL);
! return (entry != NULL) ? entry->klass() : (Klass*)NULL;
}
void Dictionary::add_protection_domain(int index, unsigned int hash,
! instanceKlassHandle klass,
ClassLoaderData* loader_data, Handle protection_domain,
TRAPS) {
Symbol* klass_name = klass->name();
DictionaryEntry* entry = get_entry(index, hash, klass_name, loader_data);
--- 408,452 ----
}
return NULL;
}
! InstanceKlass* Dictionary::find(int index, unsigned int hash, Symbol* name,
ClassLoaderData* loader_data, Handle protection_domain, TRAPS) {
DictionaryEntry* entry = get_entry(index, hash, name, loader_data);
if (entry != NULL && entry->is_valid_protection_domain(protection_domain)) {
return entry->klass();
} else {
return NULL;
}
}
! InstanceKlass* Dictionary::find_class(int index, unsigned int hash,
Symbol* name, ClassLoaderData* loader_data) {
assert_locked_or_safepoint(SystemDictionary_lock);
assert (index == index_for(name, loader_data), "incorrect index?");
DictionaryEntry* entry = get_entry(index, hash, name, loader_data);
! return (entry != NULL) ? entry->klass() : NULL;
}
// Variant of find_class for shared classes. No locking required, as
// that table is static.
! InstanceKlass* Dictionary::find_shared_class(int index, unsigned int hash,
Symbol* name) {
assert (index == index_for(name, NULL), "incorrect index?");
DictionaryEntry* entry = get_entry(index, hash, name, NULL);
! return (entry != NULL) ? entry->klass() : NULL;
}
void Dictionary::add_protection_domain(int index, unsigned int hash,
! InstanceKlass* klass,
ClassLoaderData* loader_data, Handle protection_domain,
TRAPS) {
Symbol* klass_name = klass->name();
DictionaryEntry* entry = get_entry(index, hash, klass_name, loader_data);
< prev index next >