< prev index next >

src/share/vm/classfile/dictionary.cpp

Print this page




  63   entry->set_loader_data(loader_data);
  64   entry->set_pd_set(NULL);
  65   assert(klass->oop_is_instance(), "Must be");
  66   return entry;
  67 }
  68 
  69 
  70 void Dictionary::free_entry(DictionaryEntry* entry) {
  71   // avoid recursion when deleting linked list
  72   while (entry->pd_set() != NULL) {
  73     ProtectionDomainEntry* to_delete = entry->pd_set();
  74     entry->set_pd_set(to_delete->next());
  75     delete to_delete;
  76   }
  77   Hashtable<Klass*, mtClass>::free_entry(entry);
  78 }
  79 
  80 
  81 bool DictionaryEntry::contains_protection_domain(oop protection_domain) const {
  82 #ifdef ASSERT
  83   if (protection_domain == InstanceKlass::cast(klass())->protection_domain()) {

  84     // Ensure this doesn't show up in the pd_set (invariant)
  85     bool in_pd_set = false;
  86     for (ProtectionDomainEntry* current = _pd_set;
  87                                 current != NULL;
  88                                 current = current->next()) {
  89       if (current->protection_domain() == protection_domain) {
  90         in_pd_set = true;
  91         break;
  92       }
  93     }
  94     if (in_pd_set) {
  95       assert(false, "A klass's protection domain should not show up "
  96                     "in its sys. dict. PD set");
  97     }
  98   }
  99 #endif /* ASSERT */
 100 
 101   if (protection_domain == InstanceKlass::cast(klass())->protection_domain()) {
 102     // Succeeds trivially
 103     return true;
 104   }
 105 
 106   for (ProtectionDomainEntry* current = _pd_set;
 107                               current != NULL;
 108                               current = current->next()) {
 109     if (current->protection_domain() == protection_domain) return true;
 110   }
 111   return false;
 112 }
 113 
 114 
 115 void DictionaryEntry::add_protection_domain(Dictionary* dict, oop protection_domain) {
 116   assert_locked_or_safepoint(SystemDictionary_lock);
 117   if (!contains_protection_domain(protection_domain)) {
 118     ProtectionDomainCacheEntry* entry = dict->cache_get(protection_domain);
 119     ProtectionDomainEntry* new_head =
 120                 new ProtectionDomainEntry(entry, _pd_set);
 121     // Warning: Preserve store ordering.  The SystemDictionary is read
 122     //          without locks.  The new ProtectionDomainEntry must be
 123     //          complete before other threads can be allowed to see it
 124     //          via a store to _pd_set.
 125     OrderAccess::release_store_ptr(&_pd_set, new_head);
 126   }
 127   if (TraceProtectionDomainVerification && WizardMode) {
 128     print();
 129   }


 760       ClassLoaderData* loader_data = probe->loader_data();
 761       guarantee(e->oop_is_instance(),
 762                               "Verify of system dictionary failed");
 763       // class loader must be present;  a null class loader is the
 764       // boostrap loader
 765       guarantee(loader_data != NULL || DumpSharedSpaces ||
 766                 loader_data->class_loader() == NULL ||
 767                 loader_data->class_loader()->is_instance(),
 768                 "checking type of class_loader");
 769       e->verify();
 770       probe->verify_protection_domain_set();
 771       element_count++;
 772     }
 773   }
 774   guarantee(number_of_entries() == element_count,
 775             "Verify of system dictionary failed");
 776   debug_only(verify_lookup_length((double)number_of_entries() / table_size()));
 777 
 778   _pd_cache_table->verify();
 779 }
 780 


  63   entry->set_loader_data(loader_data);
  64   entry->set_pd_set(NULL);
  65   assert(klass->oop_is_instance(), "Must be");
  66   return entry;
  67 }
  68 
  69 
  70 void Dictionary::free_entry(DictionaryEntry* entry) {
  71   // avoid recursion when deleting linked list
  72   while (entry->pd_set() != NULL) {
  73     ProtectionDomainEntry* to_delete = entry->pd_set();
  74     entry->set_pd_set(to_delete->next());
  75     delete to_delete;
  76   }
  77   Hashtable<Klass*, mtClass>::free_entry(entry);
  78 }
  79 
  80 
  81 bool DictionaryEntry::contains_protection_domain(oop protection_domain) const {
  82 #ifdef ASSERT
  83   protection_domain = oopDesc::bs()->write_barrier(protection_domain);
  84   if (protection_domain == oopDesc::bs()->write_barrier(InstanceKlass::cast(klass())->protection_domain())) {
  85     // Ensure this doesn't show up in the pd_set (invariant)
  86     bool in_pd_set = false;
  87     for (ProtectionDomainEntry* current = _pd_set;
  88                                 current != NULL;
  89                                 current = current->next()) {
  90       if (oopDesc::bs()->write_barrier(current->protection_domain()) == protection_domain) {
  91         in_pd_set = true;
  92         break;
  93       }
  94     }
  95     if (in_pd_set) {
  96       assert(false, "A klass's protection domain should not show up "
  97                     "in its sys. dict. PD set");
  98     }
  99   }
 100 #endif /* ASSERT */
 101 
 102   if (protection_domain == oopDesc::bs()->write_barrier(InstanceKlass::cast(klass())->protection_domain())) {
 103     // Succeeds trivially
 104     return true;
 105   }
 106 
 107   for (ProtectionDomainEntry* current = _pd_set;
 108                               current != NULL;
 109                               current = current->next()) {
 110     if (oopDesc::bs()->write_barrier(current->protection_domain()) == protection_domain) return true;
 111   }
 112   return false;
 113 }
 114 
 115 
 116 void DictionaryEntry::add_protection_domain(Dictionary* dict, oop protection_domain) {
 117   assert_locked_or_safepoint(SystemDictionary_lock);
 118   if (!contains_protection_domain(protection_domain)) {
 119     ProtectionDomainCacheEntry* entry = dict->cache_get(protection_domain);
 120     ProtectionDomainEntry* new_head =
 121                 new ProtectionDomainEntry(entry, _pd_set);
 122     // Warning: Preserve store ordering.  The SystemDictionary is read
 123     //          without locks.  The new ProtectionDomainEntry must be
 124     //          complete before other threads can be allowed to see it
 125     //          via a store to _pd_set.
 126     OrderAccess::release_store_ptr(&_pd_set, new_head);
 127   }
 128   if (TraceProtectionDomainVerification && WizardMode) {
 129     print();
 130   }


 761       ClassLoaderData* loader_data = probe->loader_data();
 762       guarantee(e->oop_is_instance(),
 763                               "Verify of system dictionary failed");
 764       // class loader must be present;  a null class loader is the
 765       // boostrap loader
 766       guarantee(loader_data != NULL || DumpSharedSpaces ||
 767                 loader_data->class_loader() == NULL ||
 768                 loader_data->class_loader()->is_instance(),
 769                 "checking type of class_loader");
 770       e->verify();
 771       probe->verify_protection_domain_set();
 772       element_count++;
 773     }
 774   }
 775   guarantee(number_of_entries() == element_count,
 776             "Verify of system dictionary failed");
 777   debug_only(verify_lookup_length((double)number_of_entries() / table_size()));
 778 
 779   _pd_cache_table->verify();
 780 }

< prev index next >