< prev index next >

src/hotspot/share/classfile/dictionary.cpp

Print this page


  50 
  51 
  52 Dictionary::Dictionary(ClassLoaderData* loader_data,
  53                        int table_size, HashtableBucket<mtClass>* t,
  54                        int number_of_entries, bool resizable)
  55   : Hashtable<InstanceKlass*, mtClass>(table_size, (int)sizeof(DictionaryEntry), t, number_of_entries),
  56     _resizable(resizable), _needs_resizing(false), _loader_data(loader_data) {
  57 };
  58 
  59 Dictionary::~Dictionary() {
  60   DictionaryEntry* probe = NULL;
  61   for (int index = 0; index < table_size(); index++) {
  62     for (DictionaryEntry** p = bucket_addr(index); *p != NULL; ) {
  63       probe = *p;
  64       *p = probe->next();
  65       free_entry(probe);
  66     }
  67   }
  68   assert(number_of_entries() == 0, "should have removed all entries");
  69   assert(new_entry_free_list() == NULL, "entry present on Dictionary's free list");
  70   free_buckets();
  71 }
  72 
  73 DictionaryEntry* Dictionary::new_entry(unsigned int hash, InstanceKlass* klass) {
  74   DictionaryEntry* entry = (DictionaryEntry*)Hashtable<InstanceKlass*, mtClass>::allocate_new_entry(hash, klass);
  75   entry->set_pd_set(NULL);
  76   assert(klass->is_instance_klass(), "Must be");
  77   return entry;
  78 }
  79 
  80 
  81 void Dictionary::free_entry(DictionaryEntry* entry) {
  82   // avoid recursion when deleting linked list
  83   // pd_set is accessed during a safepoint.
  84   while (entry->pd_set() != NULL) {
  85     ProtectionDomainEntry* to_delete = entry->pd_set();
  86     entry->set_pd_set(to_delete->next());
  87     delete to_delete;
  88   }
  89   // Unlink from the Hashtable prior to freeing
  90   unlink_entry(entry);




  50 
  51 
  52 Dictionary::Dictionary(ClassLoaderData* loader_data,
  53                        int table_size, HashtableBucket<mtClass>* t,
  54                        int number_of_entries, bool resizable)
  55   : Hashtable<InstanceKlass*, mtClass>(table_size, (int)sizeof(DictionaryEntry), t, number_of_entries),
  56     _resizable(resizable), _needs_resizing(false), _loader_data(loader_data) {
  57 };
  58 
  59 Dictionary::~Dictionary() {
  60   DictionaryEntry* probe = NULL;
  61   for (int index = 0; index < table_size(); index++) {
  62     for (DictionaryEntry** p = bucket_addr(index); *p != NULL; ) {
  63       probe = *p;
  64       *p = probe->next();
  65       free_entry(probe);
  66     }
  67   }
  68   assert(number_of_entries() == 0, "should have removed all entries");
  69   assert(new_entry_free_list() == NULL, "entry present on Dictionary's free list");

  70 }
  71 
  72 DictionaryEntry* Dictionary::new_entry(unsigned int hash, InstanceKlass* klass) {
  73   DictionaryEntry* entry = (DictionaryEntry*)Hashtable<InstanceKlass*, mtClass>::allocate_new_entry(hash, klass);
  74   entry->set_pd_set(NULL);
  75   assert(klass->is_instance_klass(), "Must be");
  76   return entry;
  77 }
  78 
  79 
  80 void Dictionary::free_entry(DictionaryEntry* entry) {
  81   // avoid recursion when deleting linked list
  82   // pd_set is accessed during a safepoint.
  83   while (entry->pd_set() != NULL) {
  84     ProtectionDomainEntry* to_delete = entry->pd_set();
  85     entry->set_pd_set(to_delete->next());
  86     delete to_delete;
  87   }
  88   // Unlink from the Hashtable prior to freeing
  89   unlink_entry(entry);


< prev index next >