< prev index next >

src/hotspot/share/classfile/protectionDomainCache.cpp

Print this page
rev 48467 : [mq]: INIT_Access_protection_domain


  79     }
  80   }
  81 }
  82 
  83 void ProtectionDomainCacheTable::print_on(outputStream* st) const {
  84   st->print_cr("Protection domain cache table (table_size=%d, classes=%d)",
  85                table_size(), number_of_entries());
  86   for (int index = 0; index < table_size(); index++) {
  87     for (ProtectionDomainCacheEntry* probe = bucket(index);
  88                                      probe != NULL;
  89                                      probe = probe->next()) {
  90       st->print_cr("%4d: protection_domain: " PTR_FORMAT, index, p2i(probe->literal()));
  91     }
  92   }
  93 }
  94 
  95 void ProtectionDomainCacheTable::verify() {
  96   verify_table<ProtectionDomainCacheEntry>("Protection Domain Table");
  97 }
  98 



















  99 void ProtectionDomainCacheEntry::verify() {
 100   guarantee(oopDesc::is_oop(literal()), "must be an oop");
 101 }
 102 
 103 ProtectionDomainCacheEntry* ProtectionDomainCacheTable::get(Handle protection_domain) {
 104   unsigned int hash = compute_hash(protection_domain);
 105   int index = hash_to_index(hash);
 106 
 107   ProtectionDomainCacheEntry* entry = find_entry(index, protection_domain);
 108   if (entry == NULL) {
 109     entry = add_entry(index, hash, protection_domain);
 110   }
 111   return entry;
 112 }
 113 
 114 ProtectionDomainCacheEntry* ProtectionDomainCacheTable::find_entry(int index, Handle protection_domain) {
 115   for (ProtectionDomainCacheEntry* e = bucket(index); e != NULL; e = e->next()) {
 116     if (e->protection_domain() == protection_domain()) {
 117       return e;
 118     }
 119   }
 120 
 121   return NULL;
 122 }
 123 
 124 ProtectionDomainCacheEntry* ProtectionDomainCacheTable::add_entry(int index, unsigned int hash, Handle protection_domain) {
 125   assert_locked_or_safepoint(SystemDictionary_lock);
 126   assert(index == index_for(protection_domain), "incorrect index?");
 127   assert(find_entry(index, protection_domain) == NULL, "no double entry");
 128 
 129   ProtectionDomainCacheEntry* p = new_entry(hash, protection_domain);
 130   Hashtable<oop, mtClass>::add_entry(index, p);
 131   return p;
 132 }


  79     }
  80   }
  81 }
  82 
  83 void ProtectionDomainCacheTable::print_on(outputStream* st) const {
  84   st->print_cr("Protection domain cache table (table_size=%d, classes=%d)",
  85                table_size(), number_of_entries());
  86   for (int index = 0; index < table_size(); index++) {
  87     for (ProtectionDomainCacheEntry* probe = bucket(index);
  88                                      probe != NULL;
  89                                      probe = probe->next()) {
  90       st->print_cr("%4d: protection_domain: " PTR_FORMAT, index, p2i(probe->literal()));
  91     }
  92   }
  93 }
  94 
  95 void ProtectionDomainCacheTable::verify() {
  96   verify_table<ProtectionDomainCacheEntry>("Protection Domain Table");
  97 }
  98 
  99 oop ProtectionDomainCacheEntry::object() {
 100   return RootAccess<ON_PHANTOM_OOP_REF>::oop_load(literal_addr());
 101 }
 102 
 103 oop ProtectionDomainEntry::object() {
 104   return _pd_cache->object();
 105 }
 106 
 107 // The object_no_keepalive() calls peeks at the phantomly reachable oop without
 108 // keeping it alive. This is okay to do in the VM thread state if it is not
 109 // leaked out to become strongly reachable.
 110 oop ProtectionDomainCacheEntry::object_no_keepalive() {
 111   return RootAccess<ON_PHANTOM_OOP_REF | AS_NO_KEEPALIVE>::oop_load(literal_addr());
 112 }
 113 
 114 oop ProtectionDomainEntry::object_no_keepalive() {
 115   return _pd_cache->object_no_keepalive();
 116 }
 117 
 118 void ProtectionDomainCacheEntry::verify() {
 119   guarantee(oopDesc::is_oop(literal()), "must be an oop");
 120 }
 121 
 122 ProtectionDomainCacheEntry* ProtectionDomainCacheTable::get(Handle protection_domain) {
 123   unsigned int hash = compute_hash(protection_domain);
 124   int index = hash_to_index(hash);
 125 
 126   ProtectionDomainCacheEntry* entry = find_entry(index, protection_domain);
 127   if (entry == NULL) {
 128     entry = add_entry(index, hash, protection_domain);
 129   }
 130   return entry;
 131 }
 132 
 133 ProtectionDomainCacheEntry* ProtectionDomainCacheTable::find_entry(int index, Handle protection_domain) {
 134   for (ProtectionDomainCacheEntry* e = bucket(index); e != NULL; e = e->next()) {
 135     if (e->object_no_keepalive() == protection_domain()) {
 136       return e;
 137     }
 138   }
 139 
 140   return NULL;
 141 }
 142 
 143 ProtectionDomainCacheEntry* ProtectionDomainCacheTable::add_entry(int index, unsigned int hash, Handle protection_domain) {
 144   assert_locked_or_safepoint(SystemDictionary_lock);
 145   assert(index == index_for(protection_domain), "incorrect index?");
 146   assert(find_entry(index, protection_domain) == NULL, "no double entry");
 147 
 148   ProtectionDomainCacheEntry* p = new_entry(hash, protection_domain);
 149   Hashtable<oop, mtClass>::add_entry(index, p);
 150   return p;
 151 }
< prev index next >